3 source/macro.c | 7 ++++++-
5 source/menu.c | 16 +++++++++++++---
6 source/selection.c | 14 ++++++++++++--
7 4 files changed, 32 insertions(+), 7 deletions(-)
9 diff --quilt old/source/macro.c new/source/macro.c
10 --- old/source/macro.c
11 +++ new/source/macro.c
12 @@ -6094,11 +6094,11 @@ static int readStringArg(DataValue dv, c
13 *errMsg = "%s called with unknown object";
18 -void MacroApplyHook(const WindowInfo* document, const char* hook, int argc,
19 +Boolean MacroApplyHook(const WindowInfo* document, const char* hook, int argc,
20 DataValue* argv, DataValue* resultDV)
24 hookSymbol = LookupSymbol(hook);
25 @@ -6128,10 +6128,15 @@ void MacroApplyHook(const WindowInfo* do
26 (NULL == resultDV) ? &dummyResultDV : resultDV, &errMsg);
29 if (MACRO_PREEMPT == status || MACRO_ERROR == status) {
30 fprintf(stderr, "nedit: \"%s\" error: %s\n", hook, (MACRO_ERROR == status) ? errMsg : "No dialogs");
33 /* Macro is done here */
41 diff --quilt old/source/macro.h new/source/macro.h
42 --- old/source/macro.h
43 +++ new/source/macro.h
44 @@ -72,9 +72,9 @@ int CheckMacroString(Widget dialogParent
46 char *GetReplayMacro(void);
47 void ReadMacroInitFile(WindowInfo *window);
48 void ReturnShellCommandOutput(WindowInfo *window, const char *outText, int status);
50 -void MacroApplyHook(const WindowInfo* document, const char *hook, int argc,
51 +Boolean MacroApplyHook(const WindowInfo* document, const char *hook, int argc,
52 struct DataValueTag* argv, struct DataValueTag* resultDV);
54 #endif /* NEDIT_MACRO_H_INCLUDED */
55 diff --quilt old/source/menu.c new/source/menu.c
58 @@ -2884,25 +2884,35 @@ static void openAP(Widget w, XEvent *eve
60 WindowInfo *window = WidgetToWindow(w);
61 char filename[MAXPATHLEN], pathname[MAXPATHLEN];
62 DataValue* fileNameArg = (DataValue*) XtMalloc(sizeof(DataValue));
63 DataValue* resultDV = (DataValue*) XtMalloc(sizeof(DataValue));
64 + Boolean hook_successful = False;
65 + char *fileNameToOpen;
68 fprintf(stderr, "nedit: open action requires file argument\n");
72 + resultDV->tag = NO_TAG;
73 fileNameArg->tag = STRING_TAG;
74 AllocNStringNCpy(&fileNameArg->val.str, args[0], MAXPATHLEN);
75 - MacroApplyHook(window, "file_name_hook", 1, fileNameArg, resultDV);
76 + hook_successful = MacroApplyHook(window, "file_name_hook",
77 + 1, fileNameArg, resultDV);
78 XtFree((char*) fileNameArg);
80 - if (0 != ParseFilename(resultDV->val.str.rep, filename, pathname)
81 + if (hook_successful && resultDV->tag == STRING_TAG) {
82 + fileNameToOpen = resultDV->val.str.rep;
84 + fileNameToOpen = args[0];
87 + if (0 != ParseFilename(fileNameToOpen, filename, pathname)
88 || strlen(filename) + strlen(pathname) > MAXPATHLEN - 1) {
89 fprintf(stderr, "nedit: invalid file name for open action: %s\n",
94 XtFree((char*) resultDV);
96 EditExistingFile(window, filename, pathname, 0, NULL, False,
97 diff --quilt old/source/selection.c new/source/selection.c
98 --- old/source/selection.c
99 +++ new/source/selection.c
100 @@ -359,17 +359,27 @@ static void fileCB(Widget widget, Window
102 glob(nameText, GLOB_NOCHECK, NULL, &globbuf);
103 for (i = 0; i < (int) globbuf.gl_pathc; i++) {
104 DataValue* fileNameArg = (DataValue*) XtMalloc(sizeof(DataValue));
105 DataValue* resultDV = (DataValue*) XtMalloc(sizeof(DataValue));
106 + Boolean hook_successful = False;
107 + char *fileNameToOpen;
109 + resultDV->tag = NO_TAG;
110 fileNameArg->tag = STRING_TAG;
111 AllocNStringNCpy(&fileNameArg->val.str, globbuf.gl_pathv[i], MAXPATHLEN);
112 - MacroApplyHook(window, "file_name_hook", 1, fileNameArg, resultDV);
113 + hook_successful = MacroApplyHook(window, "file_name_hook",
114 + 1, fileNameArg, resultDV);
115 XtFree((char*) fileNameArg);
117 - if (ParseFilename(resultDV->val.str.rep, filename, pathname) != 0) {
118 + if (hook_successful && resultDV->tag == STRING_TAG) {
119 + fileNameToOpen = resultDV->val.str.rep;
121 + fileNameToOpen = globbuf.gl_pathv[i];
124 + if (ParseFilename(fileNameToOpen, filename, pathname) != 0) {
125 XBell(TheDisplay, 0);
127 EditExistingFile(GetPrefOpenInTab() ? window : NULL, filename,
128 pathname, 0, NULL, False, NULL, GetPrefOpenInTab(),