3 source/macro.c | 8 ++++++--
5 source/menu.c | 16 +++++++++++++---
6 source/selection.c | 14 ++++++++++++--
7 4 files changed, 32 insertions(+), 8 deletions(-)
9 diff --quilt old/source/macro.c new/source/macro.c
10 --- old/source/macro.c
11 +++ new/source/macro.c
12 @@ -6047,14 +6047,15 @@ static int readStringArg(DataValue dv, c
13 *errMsg = "%s called with unknown object";
18 -void MacroApplyHook(WindowInfo* document, const char* hook, int argc,
19 +Boolean MacroApplyHook(WindowInfo* document, const char* hook, int argc,
20 DataValue* argv, DataValue* resultDV)
23 + Boolean succ = False;
25 hookSymbol = LookupSymbol(hook);
26 if (NULL != hookSymbol && MACRO_FUNCTION_SYM == hookSymbol->type) {
27 Program* hookProg = hookSymbol->value.val.prog;
28 RestartData* restartData;
29 @@ -6093,9 +6094,12 @@ void MacroApplyHook(WindowInfo* document
32 if (MACRO_PREEMPT == status || MACRO_ERROR == status) {
33 fprintf(stderr, "nedit: \"%s\" error: %s\n", hook, (MACRO_ERROR == status) ? errMsg : "No dialogs");
35 - /* Macro is done here */
36 + /* Macro is done here without errors */
43 diff --quilt old/source/macro.h new/source/macro.h
44 --- old/source/macro.h
45 +++ new/source/macro.h
46 @@ -72,9 +72,9 @@ int CheckMacroString(Widget dialogParent
48 char *GetReplayMacro(void);
49 void ReadMacroInitFile(WindowInfo *window);
50 void ReturnShellCommandOutput(WindowInfo *window, const char *outText, int status);
52 -void MacroApplyHook(WindowInfo* document, const char *hook, int argc,
53 +Boolean MacroApplyHook(WindowInfo* document, const char *hook, int argc,
54 struct DataValueTag* argv, struct DataValueTag* resultDV);
56 #endif /* NEDIT_MACRO_H_INCLUDED */
57 diff --quilt old/source/menu.c new/source/menu.c
60 @@ -2884,25 +2884,35 @@ static void openAP(Widget w, XEvent *eve
62 WindowInfo *window = WidgetToWindow(w);
63 char filename[MAXPATHLEN], pathname[MAXPATHLEN];
64 DataValue* fileNameArg = (DataValue*) XtMalloc(sizeof(DataValue));
65 DataValue* resultDV = (DataValue*) XtMalloc(sizeof(DataValue));
66 + Boolean hook_successful = False;
67 + char *fileNameToOpen;
70 fprintf(stderr, "nedit: open action requires file argument\n");
74 + resultDV->tag = NO_TAG;
75 fileNameArg->tag = STRING_TAG;
76 AllocNStringNCpy(&fileNameArg->val.str, args[0], MAXPATHLEN);
77 - MacroApplyHook(window, "file_name_hook", 1, fileNameArg, resultDV);
78 + hook_successful = MacroApplyHook(window, "file_name_hook",
79 + 1, fileNameArg, resultDV);
80 XtFree((char*) fileNameArg);
82 - if (0 != ParseFilename(resultDV->val.str.rep, filename, pathname)
83 + if (hook_successful && resultDV->tag == STRING_TAG) {
84 + fileNameToOpen = resultDV->val.str.rep;
86 + fileNameToOpen = args[0];
89 + if (0 != ParseFilename(fileNameToOpen, filename, pathname)
90 || strlen(filename) + strlen(pathname) > MAXPATHLEN - 1) {
91 fprintf(stderr, "nedit: invalid file name for open action: %s\n",
96 XtFree((char*) resultDV);
98 EditExistingFile(window, filename, pathname, 0, NULL, False,
99 diff --quilt old/source/selection.c new/source/selection.c
100 --- old/source/selection.c
101 +++ new/source/selection.c
102 @@ -359,17 +359,27 @@ static void fileCB(Widget widget, Window
104 glob(nameText, GLOB_NOCHECK, NULL, &globbuf);
105 for (i = 0; i < (int) globbuf.gl_pathc; i++) {
106 DataValue* fileNameArg = (DataValue*) XtMalloc(sizeof(DataValue));
107 DataValue* resultDV = (DataValue*) XtMalloc(sizeof(DataValue));
108 + Boolean hook_successful = False;
109 + char *fileNameToOpen;
111 + resultDV->tag = NO_TAG;
112 fileNameArg->tag = STRING_TAG;
113 AllocNStringNCpy(&fileNameArg->val.str, globbuf.gl_pathv[i], MAXPATHLEN);
114 - MacroApplyHook(window, "file_name_hook", 1, fileNameArg, resultDV);
115 + hook_successful = MacroApplyHook(window, "file_name_hook",
116 + 1, fileNameArg, resultDV);
117 XtFree((char*) fileNameArg);
119 - if (ParseFilename(resultDV->val.str.rep, filename, pathname) != 0) {
120 + if (hook_successful && resultDV->tag == STRING_TAG) {
121 + fileNameToOpen = resultDV->val.str.rep;
123 + fileNameToOpen = globbuf.gl_pathv[i];
126 + if (ParseFilename(fileNameToOpen, filename, pathname) != 0) {
127 XBell(TheDisplay, 0);
129 EditExistingFile(GetPrefOpenInTab() ? window : NULL, filename,
130 pathname, 0, NULL, False, NULL, GetPrefOpenInTab(),