CVS update and parse-define v6
[nedit-bw.git] / pass-context-to-ops.patch
blob1ae1aa1a01261c0945f70b82946f37498dcb14e7
1 ---
3 source/interpret.c | 297 +++++-------
4 source/interpret.h | 22
5 source/macro.c | 1248 +++++++++++++++++++++++++++++++----------------------
6 source/macro.h | 2
7 4 files changed, 899 insertions(+), 670 deletions(-)
9 diff --quilt old/source/interpret.c new/source/interpret.c
10 --- old/source/interpret.c
11 +++ new/source/interpret.c
12 @@ -81,29 +81,29 @@ static const char CVSID[] = "$Id: interp
13 enum opStatusCodes {STAT_OK=2, STAT_DONE, STAT_ERROR, STAT_PREEMPT};
15 static int addLoopAddr(Inst *addr, char **msg);
16 -static void saveContext(RestartData *context);
17 -static void restoreContext(RestartData *context);
19 /* the function prototype of a operand instruction */
20 -#define OP_FUNCTION(op) static int op(void)
21 +#define OP_FUNCTION(op) static int op(RestartData *context)
23 #define OP(name, fn) OP_FUNCTION(fn);
24 #include "ops.h"
25 #undef OP
26 -static int returnValOrNone(int valOnStack);
27 -static int branchIf(Boolean trueOrFalse);
28 -static int namedArg1orN(Boolean isFirst);
30 -static int callSubroutineFromSymbol(Symbol *sym, int nArgs);
31 -static int concatenateNwithSep(int nVals, const char *sep, char **result,
32 - int leaveParams);
33 -static int makeArrayKeyFromArgs(int nArgs, char **keyString, int leaveParams);
34 +static int returnValOrNone(RestartData *context, int valOnStack);
35 +static int branchIf(RestartData *context, Boolean trueOrFalse);
36 +static int namedArg1orN(RestartData *context, Boolean isFirst);
38 +static int callSubroutineFromSymbol(RestartData *context, Symbol *sym,
39 + int nArgs);
40 +static int concatenateNwithSep(RestartData *context, int nVals, const char *sep,
41 + char **result, int leaveParams);
42 +static int makeArrayKeyFromArgs(RestartData *context, int nArgs,
43 + char **keyString, int leaveParams);
44 static void freeSymbolList(Symbol *symList);
45 static void addToGlobalSymTab(Symbol *sym);
46 static unsigned int hashNameWith(unsigned int hash, const char *name);
47 static unsigned int hashName(const char *name);
48 -static int errCheck(const char *s);
49 -static int execError(const char *s1, const char *s2);
50 +static int errCheck(RestartData *context, const char *s);
51 +static int execError(RestartData *context, const char *s1, const char *s2);
52 static rbTreeNode *arrayEmptyAllocator(void);
53 static rbTreeNode *arrayAllocateNode(rbTreeNode *src);
54 static int arrayEntryCopyToNode(rbTreeNode *dst, rbTreeNode *src);
55 @@ -136,9 +136,9 @@ static void disasmInternal(Inst *inst, i
56 #endif /* #ifndef DEBUG_ASSEMBLY */
58 #ifdef DEBUG_STACK /* for run-time instruction and stack trace */
59 -static void stackdump(int n, int extra);
60 -static void stackdumpInternal(int n, int extra);
61 -#define STACKDUMP(n, x) stackdump(n, (x) + 10)
62 +static void stackdump(RestartData *context, int n, int extra);
63 +static void stackdumpInternal(RestartData *context, int n, int extra);
64 +#define STACKDUMP(n, x) stackdump(context, n, (x) + 10)
65 #define DISASM_RT() disasm(NULL, PC - 1, 1)
66 #else /* #ifndef DEBUG_STACK */
67 #define STACKDUMP(n, x)
68 @@ -178,13 +178,6 @@ static Inst **LoopStackPtr = LoopStack;
69 static const char *ProgramName = "";
71 /* Global data for the interpreter */
72 -static DataValue *TheStack; /* the stack */
73 -static DataValue *StackP; /* next free spot on stack */
74 -static DataValue *FrameP; /* frame pointer (start of local variables
75 - for the current subroutine invocation) */
76 -static Inst *PC; /* program counter during execution */
77 -static char *ErrMsg; /* global for returning error messages
78 - from executing functions */
79 static WindowInfo
80 *InitiatingWindow = NULL; /* window from which macro was run */
81 static WindowInfo *FocusWindow; /* window on which macro commands operate */
82 @@ -536,7 +529,7 @@ static int setupFrame(RestartData *conte
84 /* !OK_TO_PUSH(totalPushs) */
85 if (!((context->stackP + totalPushs) <= &context->stack[STACK_SIZE])) {
86 - return execError(StackOverflowMsg, "");
87 + return execError(context, StackOverflowMsg, "");
90 /* Push arguments and caller information onto the stack */
91 @@ -599,30 +592,30 @@ static int setupFrame(RestartData *conte
92 return STAT_OK;
95 -static Inst *rewindFrame(DataValue **frameP, DataValue **stackP)
96 +static void rewindFrame(RestartData *context)
98 /* get stored return information */
99 - int nArgs = FP_GET_ARG_COUNT(*frameP);
100 - DataValue *newFrameP = FP_GET_OLD_FP(*frameP);
101 - Inst *newPC = FP_GET_RET_PC(*frameP);
102 - Program *prog = FP_GET_PROG(*frameP);
103 + int nArgs = FP_GET_ARG_COUNT(context->frameP);
104 + DataValue *newFrameP = FP_GET_OLD_FP(context->frameP);
105 + Inst *newPC = FP_GET_RET_PC(context->frameP);
106 + Program *prog = FP_GET_PROG(context->frameP);
108 /* pop past local variables */
109 - *stackP = *frameP;
110 + context->stackP = context->frameP;
111 /* pop past arguments */
112 - *stackP -= (FP_TO_ARGS_DIST + nArgs);
113 + context->stackP -= (FP_TO_ARGS_DIST + nArgs);
115 - *frameP = newFrameP;
116 + context->frameP = newFrameP;
118 FreeProgram(prog);
120 - return newPC;
121 + context->pc = newPC;
124 static void rewindStack(RestartData *context)
126 while (context->pc) {
127 - context->pc = rewindFrame(&context->frameP, &context->stackP);
128 + rewindFrame(context);
132 @@ -665,7 +658,7 @@ int ExecuteMacro(WindowInfo *window, Pro
133 prog->name ? prog->name : "<exec-macro>");
135 if (status == STAT_ERROR) {
136 - *msg = ErrMsg;
137 + *msg = context->errMsg;
138 FreeRestartData(context);
139 return MACRO_ERROR;
141 @@ -682,25 +675,23 @@ int ContinueMacro(RestartData *continuat
143 register int status, instCount = 0;
144 register Inst *inst;
145 - RestartData oldContext;
147 - /* To allow macros to be invoked arbitrarily (such as those automatically
148 - triggered within smart-indent) within executing macros, this call is
149 - reentrant. */
150 - saveContext(&oldContext);
152 + WindowInfo *oldRunWindow = InitiatingWindow;
153 + WindowInfo *oldFocusWindow = FocusWindow;
156 ** Execution Loop: Call the succesive routine addresses in the program
157 ** until one returns something other than STAT_OK, then take action
159 - restoreContext(continuation);
160 - ErrMsg = NULL;
161 + InitiatingWindow = continuation->runWindow;
162 + FocusWindow = continuation->focusWindow;
163 + continuation->errMsg = NULL;
164 for (;;) {
166 /* Execute an instruction */
167 - inst = PC++;
168 + inst = continuation->pc++;
169 if (inst->type != OP_INST) {
170 - status = execError("Unexpected instruction of type %s",
171 + status = execError(continuation,
172 + "Unexpected instruction of type %s",
173 instTypeToStr(inst->type));
175 else {
176 @@ -708,31 +699,34 @@ int ContinueMacro(RestartData *continuat
177 #define OP(name, fn) case OP_##name:
178 #include "ops.h"
179 #undef OP
180 - status = (OpFns[inst->val.op])();
181 + status = (OpFns[inst->val.op])(continuation);
182 break;
183 default:
184 - status = execError("Illegal instruction at %8p", (char *)inst);
185 + status = execError(continuation, "Illegal instruction at %8p",
186 + (char *)inst);
190 /* If error return was not STAT_OK, return to caller */
191 if (status != STAT_OK) {
192 if (status == STAT_PREEMPT) {
193 - saveContext(continuation);
194 - restoreContext(&oldContext);
195 + continuation->runWindow = InitiatingWindow;
196 + continuation->focusWindow = FocusWindow;
197 + InitiatingWindow = oldRunWindow;
198 + FocusWindow = oldFocusWindow;
199 return MACRO_PREEMPT;
200 } else if (status == STAT_ERROR) {
201 - *msg = ErrMsg;
202 - saveContext(continuation);
203 + *msg = continuation->errMsg;
204 FreeRestartData(continuation);
205 - restoreContext(&oldContext);
206 + InitiatingWindow = oldRunWindow;
207 + FocusWindow = oldFocusWindow;
208 return MACRO_ERROR;
209 } else if (status == STAT_DONE) {
210 *msg = "";
211 - *result = *--StackP;
212 - saveContext(continuation);
213 + *result = *--continuation->stackP;
214 FreeRestartData(continuation);
215 - restoreContext(&oldContext);
216 + InitiatingWindow = oldRunWindow;
217 + FocusWindow = oldFocusWindow;
218 return MACRO_DONE;
221 @@ -742,8 +736,10 @@ int ContinueMacro(RestartData *continuat
222 X, other macros, and other shell scripts a chance to execute */
223 instCount++;
224 if (instCount >= INSTRUCTION_LIMIT) {
225 - saveContext(continuation);
226 - restoreContext(&oldContext);
227 + continuation->runWindow = InitiatingWindow;
228 + continuation->focusWindow = FocusWindow;
229 + InitiatingWindow = oldRunWindow;
230 + FocusWindow = oldFocusWindow;
231 return MACRO_TIME_LIMIT;
234 @@ -765,7 +761,7 @@ int RunMacroAsSubrCall(RestartData *cont
235 prog->name ? prog->name : "<run-macro>");
237 if (status == STAT_ERROR) {
238 - *msg = ErrMsg;
239 + *msg = context->errMsg;
240 FreeRestartData(context);
241 return MACRO_ERROR;
243 @@ -800,8 +796,8 @@ void PreemptMacro(void)
245 void ModifyReturnedValue(RestartData *context, DataValue dv)
247 - if ((context->pc-1)->val.op == OP_FETCH_RET_VAL)
248 - *(context->stackP-1) = dv;
249 + if ((context->pc - 1)->val.op == OP_FETCH_RET_VAL)
250 + *(context->stackP - 1) = dv;
254 @@ -1319,29 +1315,6 @@ void GarbageCollectStrings(void)
255 #endif
259 -** Save and restore execution context to data structure "context"
261 -static void saveContext(RestartData *context)
263 - context->stack = TheStack;
264 - context->stackP = StackP;
265 - context->frameP = FrameP;
266 - context->pc = PC;
267 - context->runWindow = InitiatingWindow;
268 - context->focusWindow = FocusWindow;
271 -static void restoreContext(RestartData *context)
273 - TheStack = context->stack;
274 - StackP = context->stackP;
275 - FrameP = context->frameP;
276 - PC = context->pc;
277 - InitiatingWindow = context->runWindow;
278 - FocusWindow = context->focusWindow;
281 static void freeSymbolList(Symbol *symList)
283 Symbol *s;
284 @@ -1378,7 +1351,12 @@ static void addToGlobalSymTab(Symbol *sy
285 GlobalSymTab[idx] = sym;
288 -#define EXEC_ERROR(s1, s2) return execError(s1, s2)
289 +#define StackP (context->stackP)
290 +#define TheStack (context->stack)
291 +#define FrameP (context->frameP)
292 +#define PC (context->pc)
294 +#define EXEC_ERROR(s1, s2) return execError(context, s1, s2)
296 #define GET_SYM(s) \
297 do { \
298 @@ -1386,7 +1364,8 @@ static void addToGlobalSymTab(Symbol *sy
299 EXEC_ERROR("Unexpected instruction, expected <symbol>: %s", \
300 instTypeToStr(PC->type)); \
302 - s = PC++->val.sym; \
303 + s = PC->val.sym; \
304 + PC++; \
305 } while (0)
307 #define GET_IMMED(i) \
308 @@ -1395,7 +1374,8 @@ static void addToGlobalSymTab(Symbol *sy
309 EXEC_ERROR("Unexpected instruction, expected <immediate>: %s", \
310 instTypeToStr(PC->type)); \
312 - i = PC++->val.immed; \
313 + i = PC->val.immed; \
314 + PC++; \
315 } while (0)
317 #define GET_BRANCH(a) \
318 @@ -1617,10 +1597,8 @@ OP_FUNCTION(pushSymVal)
319 symVal = FRAME_GET_ARG_N(argNum);
321 } else if (s->type == PROC_VALUE_SYM) {
322 - char *errMsg;
323 - if (!(s->value.val.subr)(FocusWindow, NULL, 0,
324 - &symVal, &errMsg)) {
325 - EXEC_ERROR(errMsg, s->name);
326 + if (!s->value.val.subr(context, NULL, 0, &symVal)) {
327 + EXEC_ERROR(context->errMsg, s->name);
329 } else if (s->type == C_FUNCTION_SYM
330 || s->type == MACRO_FUNCTION_SYM
331 @@ -1885,7 +1863,7 @@ OP_FUNCTION(anonArrayIndexVal)
332 POP(exprVal);
334 /* the next nDim stack entries form the index */
335 - errNum = makeArrayKeyFromArgs(nDim, &keyString, 0);
336 + errNum = makeArrayKeyFromArgs(context, nDim, &keyString, 0);
337 if (errNum != STAT_OK) {
338 return errNum;
340 @@ -1947,7 +1925,7 @@ OP_FUNCTION(anonArrayClose)
342 OP_FUNCTION(namedArg1)
344 - return namedArg1orN(True);
345 + return namedArg1orN(context, True);
349 @@ -1961,13 +1939,13 @@ OP_FUNCTION(namedArg1)
351 OP_FUNCTION(namedArgN)
353 - return namedArg1orN(False);
354 + return namedArg1orN(context, False);
358 ** implementation for namedArg1(), namedArgN()
360 -static int namedArg1orN(Boolean isFirst)
361 +static int namedArg1orN(RestartData *context, Boolean isFirst)
363 int errNum;
364 char *keyString = NULL;
365 @@ -1983,7 +1961,7 @@ static int namedArg1orN(Boolean isFirst)
366 POP(exprVal);
368 /* the next nDim stack entries form the index */
369 - errNum = makeArrayKeyFromArgs(nDim, &keyString, 0);
370 + errNum = makeArrayKeyFromArgs(context, nDim, &keyString, 0);
371 if (errNum != STAT_OK) {
372 return errNum;
374 @@ -2102,7 +2080,7 @@ OP_FUNCTION(arrayIndex)
375 STACKDUMP(nDim+3, 3);
377 /* the next nDim stack entries form the index */
378 - errNum = makeArrayKeyFromArgs(nDim, &keyString, False);
379 + errNum = makeArrayKeyFromArgs(context, nDim, &keyString, False);
380 if (errNum != STAT_OK) {
381 return errNum;
383 @@ -2424,8 +2402,8 @@ OP_FUNCTION(eq)
384 /* negated eq() call */
385 OP_FUNCTION(ne)
387 - eq();
388 - return not();
389 + eq(context);
390 + return not(context);
394 @@ -2616,7 +2594,7 @@ OP_FUNCTION(power)
397 PUSH_INT(n3);
398 - return errCheck("exponentiation");
399 + return errCheck(context, "exponentiation");
403 @@ -2627,8 +2605,8 @@ OP_FUNCTION(power)
404 ** stack elements. The stack elements are popped from the stack if leaveParams
405 ** is false.
407 -static int concatenateNwithSep(int nVals, const char *sep, char **result,
408 - int leaveParams)
409 +static int concatenateNwithSep(RestartData *context, int nVals, const char *sep,
410 + char **result, int leaveParams)
412 DataValue value;
413 char *res = NULL;
414 @@ -2711,7 +2689,7 @@ OP_FUNCTION(concat)
416 STACKDUMP(nExpr, 3);
418 - len = concatenateNwithSep(nExpr, "", &out, False);
419 + len = concatenateNwithSep(context, nExpr, "", &out, False);
420 if (len < 0) {
421 EXEC_ERROR("can only concatenate with string or integer", NULL);
423 @@ -2745,7 +2723,8 @@ OP_FUNCTION(concat)
424 ** or: Prog-> (in called)next, ... -- (macro code called subr)
425 ** TheStack-> symN-sym1(FP), nArgs, oldFP, retPC, argArray, argN-arg1, next, ...
427 -static int callSubroutineFromSymbol(Symbol *sym, int nArgs)
428 +static int callSubroutineFromSymbol(RestartData *context, Symbol *sym,
429 + int nArgs)
431 Symbol *s;
432 int i;
433 @@ -2788,9 +2767,9 @@ static int callSubroutineFromSymbol(Symb
435 /* Call the function and check for preemption */
436 PreemptRequest = False;
437 - if (!sym->value.val.subr(FocusWindow, StackP,
438 - nArgs, &result, &errMsg))
439 - EXEC_ERROR(errMsg, sym->name);
440 + if (!sym->value.val.subr(context, StackP, nArgs, &result)) {
441 + EXEC_ERROR(context->errMsg, sym->name);
443 PUSH_RET_VAL(result);
444 return PreemptRequest ? STAT_PREEMPT : STAT_OK;
446 @@ -2803,15 +2782,10 @@ static int callSubroutineFromSymbol(Symb
447 ** values which are already there.
449 if (sym->type == MACRO_FUNCTION_SYM) {
450 - RestartData context;
451 - int status;
452 prog = sym->value.val.prog;
453 prog->refcount++;
454 /* -nArgs means 'arguments are on stack' */
455 - saveContext(&context);
456 - status = setupFrame(&context, prog, -nArgs, NULL, argArray, sym->name);
457 - restoreContext(&context);
458 - return status;
459 + return setupFrame(context, prog, -nArgs, NULL, argArray, sym->name);
463 @@ -2833,11 +2807,11 @@ static int callSubroutineFromSymbol(Symb
464 timestamps, a marker to indicate that the call was from a macro
465 (to stop shell commands from putting up their own separate banner) */
466 disp=XtDisplay(InitiatingWindow->shell);
467 - win=XtWindow(InitiatingWindow->shell);
468 + win=XtWindow(InitiatingWindow->shell);
470 key_event.type = KeyPress;
471 key_event.send_event = MACRO_EVENT_MARKER;
472 - key_event.time=XtLastTimestampProcessed(XtDisplay(InitiatingWindow->shell));
473 + key_event.time=XtLastTimestampProcessed(XtDisplay(InitiatingWindow->shell));
475 /* The following entries are just filled in to avoid problems
476 in strange cases, like calling "self_insert()" directly from the
477 @@ -2853,7 +2827,7 @@ static int callSubroutineFromSymbol(Symb
479 /* Call the action routine and check for preemption */
480 PreemptRequest = False;
481 - sym->value.val.xtproc(FocusWindow->lastFocus,
482 + sym->value.val.xtproc(MacroFocusWindow()->lastFocus,
483 (XEvent *)&key_event, argList, &numArgs);
484 XtFree((char *)argList);
485 PUSH_RET_VAL(noValue);
486 @@ -2885,7 +2859,7 @@ OP_FUNCTION(callSubroutine)
488 STACKDUMP(nArgs > 0 ? nArgs : -nArgs, 3);
490 - return callSubroutineFromSymbol(sym, nArgs);
491 + return callSubroutineFromSymbol(context, sym, nArgs);
495 @@ -2920,7 +2894,7 @@ OP_FUNCTION(callSubroutineStackedN)
496 EXEC_ERROR("array argument call to %s erroneous", sym->name);
499 - return callSubroutineFromSymbol(sym, nArgs);
500 + return callSubroutineFromSymbol(context, sym, nArgs);
504 @@ -2929,8 +2903,8 @@ OP_FUNCTION(callSubroutineStackedN)
505 ** written in macro.c. If the caller has already "consumed" stack elements,
506 ** removeArgs must indicate how many.
509 -int OverlayRoutineFromSymbol(Symbol *sym, int nArgs, int removeArgs)
510 +int OverlayRoutineFromSymbol(RestartData *context, Symbol *sym, int nArgs,
511 + int removeArgs)
513 DataValue *argArray = StackP + nArgs - removeArgs;
515 @@ -2957,7 +2931,7 @@ int OverlayRoutineFromSymbol(Symbol *sym
516 assert (argArray->tag == NO_TAG);
517 StackP = argArray;
519 - return callSubroutineFromSymbol(sym, nArgs);
520 + return callSubroutineFromSymbol(context, sym, nArgs);
524 @@ -2965,8 +2939,8 @@ int OverlayRoutineFromSymbol(Symbol *sym
525 ** OverlayRoutineFromSymbol(). In this way a piece of compiled code can be
526 ** executed in the caller's context from a function in macro.c.
529 -int OverlayRoutineFromProg(Program *prog, int nArgs, int removeArgs)
530 +int OverlayRoutineFromProg(RestartData *context, Program *prog, int nArgs,
531 + int removeArgs)
533 Symbol *sym;
534 int ret;
535 @@ -2983,7 +2957,7 @@ int OverlayRoutineFromProg(Program *prog
536 sym->next = NULL;
537 sym->added = 0;
539 - ret = OverlayRoutineFromSymbol(sym, nArgs, removeArgs);
540 + ret = OverlayRoutineFromSymbol(context, sym, nArgs, removeArgs);
542 free(sym);
544 @@ -3086,11 +3060,11 @@ OP_FUNCTION(fetchRetVal)
545 /* see comments for returnValOrNone() */
546 OP_FUNCTION(returnNoVal)
548 - return returnValOrNone(False);
549 + return returnValOrNone(context, False);
551 OP_FUNCTION(returnVal)
553 - return returnValOrNone(True);
554 + return returnValOrNone(context, True);
558 @@ -3100,7 +3074,7 @@ OP_FUNCTION(returnVal)
559 ** After: Prog-> next, ..., (in caller)[FETCH_RET_VAL?], ...
560 ** TheStack-> retVal?, next, ...
562 -static int returnValOrNone(int valOnStack)
563 +static int returnValOrNone(RestartData *context, int valOnStack)
565 DataValue retVal;
566 static DataValue noValue = {NO_TAG, {0}};
567 @@ -3116,7 +3090,7 @@ static int returnValOrNone(int valOnStac
568 retVal = noValue;
571 - PC = rewindFrame(&FrameP, &StackP);
572 + rewindFrame(context);
574 /* push returned value, if requsted */
575 PUSH_RET_VAL(retVal);
576 @@ -3154,13 +3128,13 @@ OP_FUNCTION(branch)
578 OP_FUNCTION(branchTrue)
580 - return branchIf(True);
581 + return branchIf(context, True);
583 OP_FUNCTION(branchFalse)
585 - return branchIf(False);
586 + return branchIf(context, False);
588 -static int branchIf(Boolean trueOrFalse)
589 +static int branchIf(RestartData *context, Boolean trueOrFalse)
591 int value;
592 Inst *addr;
593 @@ -3241,11 +3215,13 @@ int ArrayCopy(DataValue *dstArray, DataV
594 ** I really need to optimize the size approximation rather than assuming
595 ** a worst case size for every integer argument
597 -static int makeArrayKeyFromArgs(int nArgs, char **keyString, int leaveParams)
598 +static int makeArrayKeyFromArgs(RestartData *context, int nArgs,
599 + char **keyString, int leaveParams)
601 int len;
603 - len = concatenateNwithSep(nArgs, ARRAY_DIM_SEP, keyString, leaveParams);
604 + len = concatenateNwithSep(context, nArgs, ARRAY_DIM_SEP, keyString,
605 + leaveParams);
606 if (len < 0) {
607 EXEC_ERROR("can only index array with string or int.", NULL);
609 @@ -3561,7 +3537,7 @@ OP_FUNCTION(arrayRef)
610 STACKDUMP(nDim+1, 3);
612 if (nDim > 0) {
613 - errNum = makeArrayKeyFromArgs(nDim, &keyString, 0);
614 + errNum = makeArrayKeyFromArgs(context, nDim, &keyString, 0);
615 if (errNum != STAT_OK) {
616 return(errNum);
618 @@ -3615,7 +3591,7 @@ OP_FUNCTION(arrayAssign)
619 if (nDim > 0) {
620 POP(srcValue);
622 - errNum = makeArrayKeyFromArgs(nDim, &keyString, 0);
623 + errNum = makeArrayKeyFromArgs(context, nDim, &keyString, 0);
624 if (errNum != STAT_OK) {
625 return(errNum);
627 @@ -3671,7 +3647,7 @@ OP_FUNCTION(arrayRefAndAssignSetup)
630 if (nDim > 0) {
631 - errNum = makeArrayKeyFromArgs(nDim, &keyString, 1);
632 + errNum = makeArrayKeyFromArgs(context, nDim, &keyString, 1);
633 if (errNum != STAT_OK) {
634 return(errNum);
636 @@ -4107,7 +4083,7 @@ OP_FUNCTION(deleteArrayElement)
637 if (nDim > 0) {
638 int errNum;
640 - errNum = makeArrayKeyFromArgs(nDim, &keyString, 0);
641 + errNum = makeArrayKeyFromArgs(context, nDim, &keyString, 0);
642 if (errNum != STAT_OK) {
643 return(errNum);
645 @@ -4251,7 +4227,7 @@ OP_FUNCTION(arrayNextNumIdx)
646 ** checks errno after operations which can set it. If an error occured,
647 ** creates appropriate error messages and returns false
649 -static int errCheck(const char *s)
650 +static int errCheck(RestartData *context, const char *s)
652 if (errno == EDOM)
653 EXEC_ERROR("%s argument out of domain", s);
654 @@ -4264,25 +4240,25 @@ static int errCheck(const char *s)
656 ** build a stack dump string, reallocating s as necessary.
658 -static char *stackDumpStr(DataValue *fp, const char *msg, char **s, int *pLen)
659 +static void stackDumpStr(RestartData *context, const char *msg, char **s, int *pLen)
661 int len;
662 const char *op;
663 char *np;
664 - DataValue *nfp = fp;
665 + DataValue *nfp = context->frameP;
666 Inst *pc;
668 #ifdef DEBUG_STACK
669 const char *dump;
670 printd("\n\n");
671 - disasmInternal(PC - 1, 1);
672 - stackdumpInternal(0, 50);
673 + disasmInternal(context->pc - 1, 1);
674 + stackdumpInternal(context, 0, 50);
675 dump = printd(NULL);
676 #endif
678 /* first measure the lengths */
679 len = strlen(msg) + 1;
680 - nfp = fp;
681 + nfp = context->frameP;
682 do {
683 len = len + FP_GET_ITEM(nfp, FP_FUNCTION_NAME).val.str.len + 1;
684 pc = FP_GET_RET_PC(nfp);
685 @@ -4302,7 +4278,7 @@ static char *stackDumpStr(DataValue *fp,
686 while (*op)
687 *np++ = *op++;
689 - nfp = fp;
690 + nfp = context->frameP;
691 do {
692 *np++ = '\n';
693 op = FP_GET_ITEM(nfp, FP_FUNCTION_NAME).val.str.rep;
694 @@ -4318,22 +4294,22 @@ static char *stackDumpStr(DataValue *fp,
695 #endif
697 *np = 0;
698 - return *s;
699 + context->errMsg = *s;
703 -** combine two strings in a static area and set ErrMsg to point to the
704 -** result. Returns false so a single return execError() statement can
705 +** combine two strings in a static area and set continuation->errMsg to point
706 +** to the result. Returns false so a single return execError() statement can
707 ** be used to both process the message and return.
709 -static int execError(const char *s1, const char *s2)
710 +static int execError(RestartData *context, const char *s1, const char *s2)
712 static char msg[MAX_ERR_MSG_LEN];
713 static char *err = NULL;
714 static int errlen = 0;
716 sprintf(msg, s1, s2);
717 - ErrMsg = stackDumpStr(FrameP, msg, &err, &errlen);
718 + stackDumpStr(context, msg, &err, &errlen);
719 return STAT_ERROR;
722 @@ -4445,6 +4421,11 @@ static const char *instTypeToStr(enum in
726 +#undef StackP
727 +#undef TheStack
728 +#undef FrameP
729 +#undef PC
731 #ifdef DEBUG_DISASSEMBLER /* dumping values in disassembly or stack dump */
732 static char *printdBuffer = NULL;
733 static int printdPos = 0;
734 @@ -4905,31 +4886,31 @@ static void stackdumpframe(DataValue *ar
735 #endif /* #ifdef DEBUG_STACK_HEADFIRST */
738 -static void stackdumpInternal(int n, int extra)
739 +static void stackdumpInternal(RestartData *context, int n, int extra)
741 - DataValue *arrow = StackP - n;
742 - DataValue *outpt = StackP - n - extra;
743 + DataValue *arrow = context->stackP - n;
744 + DataValue *outpt = context->stackP - n - extra;
746 #ifdef DEBUG_STACK_HEADFIRST
747 printd("Stack ----->\n");
748 - stackdumpframe(arrow, outpt, FrameP, StackP, '*');
749 - if (outpt < TheStack)
750 + stackdumpframe(arrow, outpt, context->frameP, context->stackP, '*');
751 + if (outpt < context->stack)
752 printd("--------------Stack base--------------\n");
753 #else
754 - if (outpt < TheStack)
755 + if (outpt < context->stack)
756 printd("--------------Stack base--------------\n");
757 - stackdumpframe(arrow, outpt, FrameP, StackP, '*');
758 + stackdumpframe(arrow, outpt, context->frameP, context->stackP, '*');
759 printd("Stack ----->\n\n");
760 #endif /* #ifdef DEBUG_STACK_HEADFIRST */
763 -static void stackdump(int n, int extra)
764 +static void stackdump(RestartData *context, int n, int extra)
766 static int outIsTTY = -1;
767 if (outIsTTY == -1)
768 outIsTTY = isatty(fileno(stdout));
770 - stackdumpInternal(n, extra);
771 + stackdumpInternal(context, n, extra);
773 if (outIsTTY)
774 printd("\033[J\n");
775 diff --quilt old/source/interpret.h new/source/interpret.h
776 --- old/source/interpret.h
777 +++ new/source/interpret.h
778 @@ -62,6 +62,7 @@ struct DataValueTag;
779 struct SparseArrayEntryTag;
780 struct ProgramTag;
781 struct SymbolRec;
782 +struct RestartDataTag;
784 typedef struct InstTag {
785 enum instTypes type;
786 @@ -73,8 +74,8 @@ typedef struct InstTag {
787 } val;
788 } Inst;
790 -typedef int (*BuiltInSubr)(WindowInfo *window, struct DataValueTag *argList,
791 - int nArgs, struct DataValueTag *result, char **errMsg);
792 +typedef int (BuiltInSubr)(struct RestartDataTag *context,
793 + struct DataValueTag *argList, int nArgs, struct DataValueTag *result);
795 typedef struct NStringTag {
796 char *rep;
797 @@ -86,11 +87,11 @@ typedef struct DataValueTag {
798 union {
799 int n;
800 struct NStringTag str;
801 - BuiltInSubr subr;
802 - struct ProgramTag* prog;
803 + BuiltInSubr *subr;
804 + struct ProgramTag *prog;
805 XtActionProc xtproc;
806 - Inst* inst;
807 - struct DataValueTag* dataval;
808 + Inst *inst;
809 + struct DataValueTag *dataval;
810 struct SparseArrayEntryTag *arrayPtr;
811 struct SymbolRec *sym;
812 } val;
813 @@ -120,13 +121,14 @@ typedef struct ProgramTag {
814 } Program;
816 /* Information needed to re-start a preempted macro */
817 -typedef struct {
818 +typedef struct RestartDataTag {
819 DataValue *stack;
820 DataValue *stackP;
821 DataValue *frameP;
822 Inst *pc;
823 WindowInfo *runWindow;
824 WindowInfo *focusWindow;
825 + char *errMsg;
826 } RestartData;
828 /* state of the accumulator (aka compiler) */
829 @@ -183,8 +185,10 @@ int ContinueMacro(RestartData *continuat
830 int RunMacroAsSubrCall(RestartData *context, Program *prog, char **msg);
831 void PreemptMacro(void);
833 -int OverlayRoutineFromProg(Program *prog, int nArgs, int removeArgs);
834 -int OverlayRoutineFromSymbol(Symbol *sym, int nArgs, int removeArgs);
835 +int OverlayRoutineFromProg(RestartData *context, Program *prog, int nArgs,
836 + int removeArgs);
837 +int OverlayRoutineFromSymbol(RestartData *context, Symbol *sym, int nArgs,
838 + int removeArgs);
840 char *AllocString(int length);
841 char *AllocStringNCpy(const char *s, int length);
842 diff --quilt old/source/macro.c new/source/macro.c
843 --- old/source/macro.c
844 +++ new/source/macro.c
845 @@ -170,82 +170,82 @@ static void bannerTimeoutProc(XtPointer
846 static Boolean continueWorkProc(XtPointer clientData);
847 static int escapeStringChars(char *fromString, char *toString);
848 static int escapedStringLength(char *string);
849 -static int argsMS(WindowInfo *window, DataValue *argList, int nArgs,
850 - DataValue *result, char **errMsg);
851 -static int nArgsMS(WindowInfo *window, DataValue *argList, int nArgs,
852 - DataValue *result, char **errMsg);
853 -static int lengthMS(WindowInfo *window, DataValue *argList, int nArgs,
854 - DataValue *result, char **errMsg);
855 -static int minMS(WindowInfo *window, DataValue *argList, int nArgs,
856 - DataValue *result, char **errMsg);
857 -static int maxMS(WindowInfo *window, DataValue *argList, int nArgs,
858 - DataValue *result, char **errMsg);
859 -static int focusWindowMS(WindowInfo *window, DataValue *argList, int nArgs,
860 - DataValue *result, char **errMsg);
861 -static int getRangeMS(WindowInfo *window, DataValue *argList, int nArgs,
862 - DataValue *result, char **errMsg);
863 -static int getCharacterMS(WindowInfo *window, DataValue *argList, int nArgs,
864 - DataValue *result, char **errMsg);
865 -static int replaceRangeMS(WindowInfo *window, DataValue *argList, int nArgs,
866 - DataValue *result, char **errMsg);
867 -static int replaceSelectionMS(WindowInfo *window, DataValue *argList, int nArgs,
868 - DataValue *result, char **errMsg);
869 -static int getSelectionMS(WindowInfo *window, DataValue *argList, int nArgs,
870 - DataValue *result, char **errMsg);
871 -static int validNumberMS(WindowInfo *window, DataValue *argList, int nArgs,
872 - DataValue *result, char **errMsg);
873 -static int replaceInStringMS(WindowInfo *window, DataValue *argList, int nArgs,
874 - DataValue *result, char **errMsg);
875 -static int replaceSubstringMS(WindowInfo *window, DataValue *argList, int nArgs,
876 - DataValue *result, char **errMsg);
877 -static int fullFileNameMS(WindowInfo *window, DataValue *argList, int nArgs,
878 - DataValue *result, char **errMsg);
879 -static int readFileMS(WindowInfo *window, DataValue *argList, int nArgs,
880 - DataValue *result, char **errMsg);
881 -static int writeFileMS(WindowInfo *window, DataValue *argList, int nArgs,
882 - DataValue *result, char **errMsg);
883 -static int appendFileMS(WindowInfo *window, DataValue *argList, int nArgs,
884 - DataValue *result, char **errMsg);
885 +static int argsMS(RestartData *context, DataValue *argList, int nArgs,
886 + DataValue *result);
887 +static int nArgsMS(RestartData *context, DataValue *argList, int nArgs,
888 + DataValue *result);
889 +static int lengthMS(RestartData *context, DataValue *argList, int nArgs,
890 + DataValue *result);
891 +static int minMS(RestartData *context, DataValue *argList, int nArgs,
892 + DataValue *result);
893 +static int maxMS(RestartData *context, DataValue *argList, int nArgs,
894 + DataValue *result);
895 +static int focusWindowMS(RestartData *context, DataValue *argList, int nArgs,
896 + DataValue *result);
897 +static int getRangeMS(RestartData *context, DataValue *argList, int nArgs,
898 + DataValue *result);
899 +static int getCharacterMS(RestartData *context, DataValue *argList, int nArgs,
900 + DataValue *result);
901 +static int replaceRangeMS(RestartData *context, DataValue *argList, int nArgs,
902 + DataValue *result);
903 +static int replaceSelectionMS(RestartData *context, DataValue *argList, int nArgs,
904 + DataValue *result);
905 +static int getSelectionMS(RestartData *context, DataValue *argList, int nArgs,
906 + DataValue *result);
907 +static int validNumberMS(RestartData *context, DataValue *argList, int nArgs,
908 + DataValue *result);
909 +static int replaceInStringMS(RestartData *context, DataValue *argList, int nArgs,
910 + DataValue *result);
911 +static int replaceSubstringMS(RestartData *context, DataValue *argList, int nArgs,
912 + DataValue *result);
913 +static int fullFileNameMS(RestartData *context, DataValue *argList, int nArgs,
914 + DataValue *result);
915 +static int readFileMS(RestartData *context, DataValue *argList, int nArgs,
916 + DataValue *result);
917 +static int writeFileMS(RestartData *context, DataValue *argList, int nArgs,
918 + DataValue *result);
919 +static int appendFileMS(RestartData *context, DataValue *argList, int nArgs,
920 + DataValue *result);
921 static int writeOrAppendFile(int append, WindowInfo *window,
922 DataValue *argList, int nArgs, DataValue *result, char **errMsg);
923 -static int substringMS(WindowInfo *window, DataValue *argList, int nArgs,
924 - DataValue *result, char **errMsg);
925 -static int toupperMS(WindowInfo *window, DataValue *argList, int nArgs,
926 - DataValue *result, char **errMsg);
927 -static int tolowerMS(WindowInfo *window, DataValue *argList, int nArgs,
928 - DataValue *result, char **errMsg);
929 -static int stringToClipboardMS(WindowInfo *window, DataValue *argList, int nArgs,
930 - DataValue *result, char **errMsg);
931 -static int clipboardToStringMS(WindowInfo *window, DataValue *argList, int nArgs,
932 - DataValue *result, char **errMsg);
933 -static int searchMS(WindowInfo *window, DataValue *argList, int nArgs,
934 - DataValue *result, char **errMsg);
935 -static int searchStringMS(WindowInfo *window, DataValue *argList, int nArgs,
936 - DataValue *result, char **errMsg);
937 -static int setCursorPosMS(WindowInfo *window, DataValue *argList, int nArgs,
938 - DataValue *result, char **errMsg);
939 -static int beepMS(WindowInfo *window, DataValue *argList, int nArgs,
940 - DataValue *result, char **errMsg);
941 -static int selectMS(WindowInfo *window, DataValue *argList, int nArgs,
942 - DataValue *result, char **errMsg);
943 -static int selectRectangleMS(WindowInfo *window, DataValue *argList, int nArgs,
944 - DataValue *result, char **errMsg);
945 -static int tPrintMS(WindowInfo *window, DataValue *argList, int nArgs,
946 - DataValue *result, char **errMsg);
947 -static int getenvMS(WindowInfo *window, DataValue *argList, int nArgs,
948 - DataValue *result, char **errMsg);
949 -static int shellCmdMS(WindowInfo *window, DataValue *argList, int nArgs,
950 - DataValue *result, char **errMsg);
951 -static int dialogMS(WindowInfo *window, DataValue *argList, int nArgs,
952 - DataValue *result, char **errMsg);
953 +static int substringMS(RestartData *context, DataValue *argList, int nArgs,
954 + DataValue *result);
955 +static int toupperMS(RestartData *context, DataValue *argList, int nArgs,
956 + DataValue *result);
957 +static int tolowerMS(RestartData *context, DataValue *argList, int nArgs,
958 + DataValue *result);
959 +static int stringToClipboardMS(RestartData *context, DataValue *argList, int nArgs,
960 + DataValue *result);
961 +static int clipboardToStringMS(RestartData *context, DataValue *argList, int nArgs,
962 + DataValue *result);
963 +static int searchMS(RestartData *context, DataValue *argList, int nArgs,
964 + DataValue *result);
965 +static int searchStringMS(RestartData *context, DataValue *argList, int nArgs,
966 + DataValue *result);
967 +static int setCursorPosMS(RestartData *context, DataValue *argList, int nArgs,
968 + DataValue *result);
969 +static int beepMS(RestartData *context, DataValue *argList, int nArgs,
970 + DataValue *result);
971 +static int selectMS(RestartData *context, DataValue *argList, int nArgs,
972 + DataValue *result);
973 +static int selectRectangleMS(RestartData *context, DataValue *argList, int nArgs,
974 + DataValue *result);
975 +static int tPrintMS(RestartData *context, DataValue *argList, int nArgs,
976 + DataValue *result);
977 +static int getenvMS(RestartData *context, DataValue *argList, int nArgs,
978 + DataValue *result);
979 +static int shellCmdMS(RestartData *context, DataValue *argList, int nArgs,
980 + DataValue *result);
981 +static int dialogMS(RestartData *context, DataValue *argList, int nArgs,
982 + DataValue *result);
983 static void dialogBtnCB(Widget w, XtPointer clientData, XtPointer callData);
984 static void dialogCloseCB(Widget w, XtPointer clientData, XtPointer callData);
985 #ifdef LESSTIF_VERSION
986 static void dialogEscCB(Widget w, XtPointer clientData, XEvent *event,
987 Boolean *cont);
988 #endif /* LESSTIF_VERSION */
989 -static int stringDialogMS(WindowInfo *window, DataValue *argList, int nArgs,
990 - DataValue *result, char **errMsg);
991 +static int stringDialogMS(RestartData *context, DataValue *argList, int nArgs,
992 + DataValue *result);
993 static void stringDialogBtnCB(Widget w, XtPointer clientData,
994 XtPointer callData);
995 static void stringDialogCloseCB(Widget w, XtPointer clientData,
996 @@ -254,122 +254,122 @@ static void stringDialogCloseCB(Widget w
997 static void stringDialogEscCB(Widget w, XtPointer clientData, XEvent *event,
998 Boolean *cont);
999 #endif /* LESSTIF_VERSION */
1000 -static int calltipMS(WindowInfo *window, DataValue *argList, int nArgs,
1001 - DataValue *result, char **errMsg);
1002 -static int killCalltipMS(WindowInfo *window, DataValue *argList, int nArgs,
1003 - DataValue *result, char **errMsg);
1004 -static int highlightCTLineMS(WindowInfo *window, DataValue *argList, int nArgs,
1005 - DataValue *result, char **errMsg);
1006 +static int calltipMS(RestartData *context, DataValue *argList, int nArgs,
1007 + DataValue *result);
1008 +static int killCalltipMS(RestartData *context, DataValue *argList, int nArgs,
1009 + DataValue *result);
1010 +static int highlightCTLineMS(RestartData *context, DataValue *argList, int nArgs,
1011 + DataValue *result);
1012 /* T Balinski */
1013 -static int listDialogMS(WindowInfo *window, DataValue *argList, int nArgs,
1014 - DataValue *result, char **errMsg);
1015 +static int listDialogMS(RestartData *context, DataValue *argList, int nArgs,
1016 + DataValue *result);
1017 static void listDialogBtnCB(Widget w, XtPointer clientData,
1018 - XtPointer callData);
1019 + XtPointer callData);
1020 static void listDialogCloseCB(Widget w, XtPointer clientData,
1021 - XtPointer callData);
1022 + XtPointer callData);
1023 /* T Balinski End */
1024 #ifdef LESSTIF_VERSION
1025 static void listDialogEscCB(Widget w, XtPointer clientData, XEvent *event,
1026 Boolean *cont);
1027 #endif /* LESSTIF_VERSION */
1028 -static int stringCompareMS(WindowInfo *window, DataValue *argList, int nArgs,
1029 - DataValue *result, char **errMsg);
1030 -static int splitMS(WindowInfo *window, DataValue *argList, int nArgs,
1031 - DataValue *result, char **errMsg);
1032 -static int joinMS(WindowInfo *window, DataValue *argList, int nArgs,
1033 - DataValue *result, char **errMsg);
1034 +static int stringCompareMS(RestartData *context, DataValue *argList, int nArgs,
1035 + DataValue *result);
1036 +static int splitMS(RestartData *context, DataValue *argList, int nArgs,
1037 + DataValue *result);
1038 +static int joinMS(RestartData *context, DataValue *argList, int nArgs,
1039 + DataValue *result);
1040 /* DISASBLED for 5.4
1041 -static int setBacklightStringMS(WindowInfo *window, DataValue *argList,
1042 - int nArgs, DataValue *result, char **errMsg);
1043 +static int setBacklightStringMS(RestartData *context, DataValue *argList,
1044 + int nArgs, DataValue *result);
1046 -static int cursorMV(WindowInfo *window, DataValue *argList, int nArgs,
1047 - DataValue *result, char **errMsg);
1048 -static int lineMV(WindowInfo *window, DataValue *argList, int nArgs,
1049 - DataValue *result, char **errMsg);
1050 -static int columnMV(WindowInfo *window, DataValue *argList, int nArgs,
1051 - DataValue *result, char **errMsg);
1052 -static int fileNameMV(WindowInfo *window, DataValue *argList, int nArgs,
1053 - DataValue *result, char **errMsg);
1054 -static int filePathMV(WindowInfo *window, DataValue *argList, int nArgs,
1055 - DataValue *result, char **errMsg);
1056 -static int lengthMV(WindowInfo *window, DataValue *argList, int nArgs,
1057 - DataValue *result, char **errMsg);
1058 -static int selectionStartMV(WindowInfo *window, DataValue *argList, int nArgs,
1059 - DataValue *result, char **errMsg);
1060 -static int selectionEndMV(WindowInfo *window, DataValue *argList, int nArgs,
1061 - DataValue *result, char **errMsg);
1062 -static int selectionLeftMV(WindowInfo *window, DataValue *argList, int nArgs,
1063 - DataValue *result, char **errMsg);
1064 -static int selectionRightMV(WindowInfo *window, DataValue *argList, int nArgs,
1065 - DataValue *result, char **errMsg);
1066 -static int statisticsLineMV(WindowInfo *window, DataValue *argList, int nArgs,
1067 - DataValue *result, char **errMsg);
1068 -static int incSearchLineMV(WindowInfo *window, DataValue *argList, int nArgs,
1069 - DataValue *result, char **errMsg);
1070 -static int showLineNumbersMV(WindowInfo *window, DataValue *argList, int nArgs,
1071 - DataValue *result, char **errMsg);
1072 -static int autoIndentMV(WindowInfo *window, DataValue *argList, int nArgs,
1073 - DataValue *result, char **errMsg);
1074 -static int wrapTextMV(WindowInfo *window, DataValue *argList, int nArgs,
1075 - DataValue *result, char **errMsg);
1076 -static int highlightSyntaxMV(WindowInfo *window, DataValue *argList, int nArgs,
1077 - DataValue *result, char **errMsg);
1078 -static int makeBackupCopyMV(WindowInfo *window, DataValue *argList, int nArgs,
1079 - DataValue *result, char **errMsg);
1080 -static int incBackupMV(WindowInfo *window, DataValue *argList, int nArgs,
1081 - DataValue *result, char **errMsg);
1082 -static int showMatchingMV(WindowInfo *window, DataValue *argList, int nArgs,
1083 - DataValue *result, char **errMsg);
1084 -static int overTypeModeMV(WindowInfo *window, DataValue *argList, int nArgs,
1085 - DataValue *result, char **errMsg);
1086 -static int readOnlyMV(WindowInfo *window, DataValue *argList, int nArgs,
1087 - DataValue *result, char **errMsg);
1088 -static int lockedMV(WindowInfo *window, DataValue *argList, int nArgs,
1089 - DataValue *result, char **errMsg);
1090 -static int fileFormatMV(WindowInfo *window, DataValue *argList, int nArgs,
1091 - DataValue *result, char **errMsg);
1092 -static int fontNameMV(WindowInfo *window, DataValue *argList, int nArgs,
1093 - DataValue *result, char **errMsg);
1094 -static int fontNameItalicMV(WindowInfo *window, DataValue *argList, int nArgs,
1095 - DataValue *result, char **errMsg);
1096 -static int fontNameBoldMV(WindowInfo *window, DataValue *argList, int nArgs,
1097 - DataValue *result, char **errMsg);
1098 -static int fontNameBoldItalicMV(WindowInfo *window, DataValue *argList, int nArgs,
1099 - DataValue *result, char **errMsg);
1100 -static int subscriptSepMV(WindowInfo *window, DataValue *argList, int nArgs,
1101 - DataValue *result, char **errMsg);
1102 -static int minFontWidthMV(WindowInfo *window, DataValue *argList, int nArgs,
1103 - DataValue *result, char **errMsg);
1104 -static int maxFontWidthMV(WindowInfo *window, DataValue *argList, int nArgs,
1105 - DataValue *result, char **errMsg);
1106 -static int wrapMarginMV(WindowInfo *window, DataValue *argList, int nArgs,
1107 - DataValue *result, char **errMsg);
1108 -static int topLineMV(WindowInfo *window, DataValue *argList, int nArgs,
1109 - DataValue *result, char **errMsg);
1110 -static int numDisplayLinesMV(WindowInfo *window, DataValue *argList, int nArgs,
1111 - DataValue *result, char **errMsg);
1112 -static int displayWidthMV(WindowInfo *window, DataValue *argList, int nArgs,
1113 - DataValue *result, char **errMsg);
1114 -static int activePaneMV(WindowInfo *window, DataValue *argList, int nArgs,
1115 - DataValue *result, char **errMsg);
1116 -static int nPanesMV(WindowInfo *window, DataValue *argList, int nArgs,
1117 - DataValue *result, char **errMsg);
1118 -static int emptyArrayMV(WindowInfo *window, DataValue *argList, int nArgs,
1119 - DataValue *result, char **errMsg);
1120 -static int serverNameMV(WindowInfo *window, DataValue *argList, int nArgs,
1121 - DataValue *result, char **errMsg);
1122 -static int tabDistMV(WindowInfo *window, DataValue *argList, int nArgs,
1123 - DataValue *result, char **errMsg);
1124 -static int emTabDistMV(WindowInfo *window, DataValue *argList, int nArgs,
1125 - DataValue *result, char **errMsg);
1126 -static int useTabsMV(WindowInfo *window, DataValue *argList, int nArgs,
1127 - DataValue *result, char **errMsg);
1128 -static int modifiedMV(WindowInfo *window, DataValue *argList, int nArgs,
1129 - DataValue *result, char **errMsg);
1130 -static int languageModeMV(WindowInfo *window, DataValue *argList, int nArgs,
1131 - DataValue *result, char **errMsg);
1132 -static int calltipIDMV(WindowInfo *window, DataValue *argList, int nArgs,
1133 - DataValue *result, char **errMsg);
1134 +static int cursorMV(RestartData *context, DataValue *argList, int nArgs,
1135 + DataValue *result);
1136 +static int lineMV(RestartData *context, DataValue *argList, int nArgs,
1137 + DataValue *result);
1138 +static int columnMV(RestartData *context, DataValue *argList, int nArgs,
1139 + DataValue *result);
1140 +static int fileNameMV(RestartData *context, DataValue *argList, int nArgs,
1141 + DataValue *result);
1142 +static int filePathMV(RestartData *context, DataValue *argList, int nArgs,
1143 + DataValue *result);
1144 +static int lengthMV(RestartData *context, DataValue *argList, int nArgs,
1145 + DataValue *result);
1146 +static int selectionStartMV(RestartData *context, DataValue *argList, int nArgs,
1147 + DataValue *result);
1148 +static int selectionEndMV(RestartData *context, DataValue *argList, int nArgs,
1149 + DataValue *result);
1150 +static int selectionLeftMV(RestartData *context, DataValue *argList, int nArgs,
1151 + DataValue *result);
1152 +static int selectionRightMV(RestartData *context, DataValue *argList, int nArgs,
1153 + DataValue *result);
1154 +static int statisticsLineMV(RestartData *context, DataValue *argList, int nArgs,
1155 + DataValue *result);
1156 +static int incSearchLineMV(RestartData *context, DataValue *argList, int nArgs,
1157 + DataValue *result);
1158 +static int showLineNumbersMV(RestartData *context, DataValue *argList, int nArgs,
1159 + DataValue *result);
1160 +static int autoIndentMV(RestartData *context, DataValue *argList, int nArgs,
1161 + DataValue *result);
1162 +static int wrapTextMV(RestartData *context, DataValue *argList, int nArgs,
1163 + DataValue *result);
1164 +static int highlightSyntaxMV(RestartData *context, DataValue *argList, int nArgs,
1165 + DataValue *result);
1166 +static int makeBackupCopyMV(RestartData *context, DataValue *argList, int nArgs,
1167 + DataValue *result);
1168 +static int incBackupMV(RestartData *context, DataValue *argList, int nArgs,
1169 + DataValue *result);
1170 +static int showMatchingMV(RestartData *context, DataValue *argList, int nArgs,
1171 + DataValue *result);
1172 +static int overTypeModeMV(RestartData *context, DataValue *argList, int nArgs,
1173 + DataValue *result);
1174 +static int readOnlyMV(RestartData *context, DataValue *argList, int nArgs,
1175 + DataValue *result);
1176 +static int lockedMV(RestartData *context, DataValue *argList, int nArgs,
1177 + DataValue *result);
1178 +static int fileFormatMV(RestartData *context, DataValue *argList, int nArgs,
1179 + DataValue *result);
1180 +static int fontNameMV(RestartData *context, DataValue *argList, int nArgs,
1181 + DataValue *result);
1182 +static int fontNameItalicMV(RestartData *context, DataValue *argList, int nArgs,
1183 + DataValue *result);
1184 +static int fontNameBoldMV(RestartData *context, DataValue *argList, int nArgs,
1185 + DataValue *result);
1186 +static int fontNameBoldItalicMV(RestartData *context, DataValue *argList, int nArgs,
1187 + DataValue *result);
1188 +static int subscriptSepMV(RestartData *context, DataValue *argList, int nArgs,
1189 + DataValue *result);
1190 +static int minFontWidthMV(RestartData *context, DataValue *argList, int nArgs,
1191 + DataValue *result);
1192 +static int maxFontWidthMV(RestartData *context, DataValue *argList, int nArgs,
1193 + DataValue *result);
1194 +static int wrapMarginMV(RestartData *context, DataValue *argList, int nArgs,
1195 + DataValue *result);
1196 +static int topLineMV(RestartData *context, DataValue *argList, int nArgs,
1197 + DataValue *result);
1198 +static int numDisplayLinesMV(RestartData *context, DataValue *argList, int nArgs,
1199 + DataValue *result);
1200 +static int displayWidthMV(RestartData *context, DataValue *argList, int nArgs,
1201 + DataValue *result);
1202 +static int activePaneMV(RestartData *context, DataValue *argList, int nArgs,
1203 + DataValue *result);
1204 +static int nPanesMV(RestartData *context, DataValue *argList, int nArgs,
1205 + DataValue *result);
1206 +static int emptyArrayMV(RestartData *context, DataValue *argList, int nArgs,
1207 + DataValue *result);
1208 +static int serverNameMV(RestartData *context, DataValue *argList, int nArgs,
1209 + DataValue *result);
1210 +static int tabDistMV(RestartData *context, DataValue *argList, int nArgs,
1211 + DataValue *result);
1212 +static int emTabDistMV(RestartData *context, DataValue *argList, int nArgs,
1213 + DataValue *result);
1214 +static int useTabsMV(RestartData *context, DataValue *argList, int nArgs,
1215 + DataValue *result);
1216 +static int modifiedMV(RestartData *context, DataValue *argList, int nArgs,
1217 + DataValue *result);
1218 +static int languageModeMV(RestartData *context, DataValue *argList, int nArgs,
1219 + DataValue *result);
1220 +static int calltipIDMV(RestartData *context, DataValue *argList, int nArgs,
1221 + DataValue *result);
1222 static int readSearchArgs(DataValue *argList, int nArgs, int*searchDirection,
1223 int *searchType, int *wrap, char **errMsg);
1224 static int wrongNArgsErr(char **errMsg);
1225 @@ -379,101 +379,101 @@ static int readIntArg(DataValue dv, int
1226 static int readStringArg(DataValue dv, char **result, char *stringStorage,
1227 char **errMsg);
1228 /* DISABLED FOR 5.4
1229 -static int backlightStringMV(WindowInfo *window, DataValue *argList,
1230 - int nArgs, DataValue *result, char **errMsg);
1231 +static int backlightStringMV(RestartData *context, DataValue *argList,
1232 + int nArgs, DataValue *result);
1234 -static int rangesetListMV(WindowInfo *window, DataValue *argList,
1235 - int nArgs, DataValue *result, char **errMsg);
1236 -static int versionMV(WindowInfo* window, DataValue* argList, int nArgs,
1237 - DataValue* result, char** errMsg);
1238 -static int neditHomeMV(WindowInfo *window, DataValue *argList, int nArgs,
1239 - DataValue *result, char **errMsg);
1240 -static int transientMV(WindowInfo *window, DataValue *argList, int nArgs,
1241 - DataValue *result, char **errMsg);
1242 -static int rangesetCreateMS(WindowInfo *window, DataValue *argList, int nArgs,
1243 - DataValue *result, char **errMsg);
1244 -static int rangesetDestroyMS(WindowInfo *window, DataValue *argList, int nArgs,
1245 - DataValue *result, char **errMsg);
1246 -static int rangesetGetByNameMS(WindowInfo *window, DataValue *argList, int nArgs,
1247 - DataValue *result, char **errMsg);
1248 -static int rangesetAddMS(WindowInfo *window, DataValue *argList, int nArgs,
1249 - DataValue *result, char **errMsg);
1250 -static int rangesetSubtractMS(WindowInfo *window, DataValue *argList, int nArgs,
1251 - DataValue *result, char **errMsg);
1252 -static int rangesetInvertMS(WindowInfo *window, DataValue *argList, int nArgs,
1253 - DataValue *result, char **errMsg);
1254 -static int rangesetInfoMS(WindowInfo *window, DataValue *argList, int nArgs,
1255 - DataValue *result, char **errMsg);
1256 -static int rangesetRangeMS(WindowInfo *window, DataValue *argList, int nArgs,
1257 - DataValue *result, char **errMsg);
1258 -static int rangesetIncludesPosMS(WindowInfo *window, DataValue *argList,
1259 - int nArgs, DataValue *result, char **errMsg);
1260 -static int rangesetSetColorMS(WindowInfo *window, DataValue *argList,
1261 - int nArgs, DataValue *result, char **errMsg);
1262 -static int rangesetSetUnderlineMS(WindowInfo *window, DataValue *argList,
1263 - int nArgs, DataValue *result, char **errMsg);
1264 -static int rangesetSetNameMS(WindowInfo *window, DataValue *argList,
1265 - int nArgs, DataValue *result, char **errMsg);
1266 -static int rangesetSetModeMS(WindowInfo *window, DataValue *argList,
1267 - int nArgs, DataValue *result, char **errMsg);
1268 +static int rangesetListMV(RestartData *context, DataValue *argList, int nArgs,
1269 + DataValue *result);
1270 +static int versionMV(RestartData *context, DataValue *argList, int nArgs,
1271 + DataValue *result);
1272 +static int neditHomeMV(RestartData *context, DataValue *argList, int nArgs,
1273 + DataValue *result);
1274 +static int transientMV(RestartData *context, DataValue *argList, int nArgs,
1275 + DataValue *result);
1276 +static int rangesetCreateMS(RestartData *context, DataValue *argList, int nArgs,
1277 + DataValue *result);
1278 +static int rangesetDestroyMS(RestartData *context, DataValue *argList, int nArgs,
1279 + DataValue *result);
1280 +static int rangesetGetByNameMS(RestartData *context, DataValue *argList, int nArgs,
1281 + DataValue *result);
1282 +static int rangesetAddMS(RestartData *context, DataValue *argList, int nArgs,
1283 + DataValue *result);
1284 +static int rangesetSubtractMS(RestartData *context, DataValue *argList, int nArgs,
1285 + DataValue *result);
1286 +static int rangesetInvertMS(RestartData *context, DataValue *argList, int nArgs,
1287 + DataValue *result);
1288 +static int rangesetInfoMS(RestartData *context, DataValue *argList, int nArgs,
1289 + DataValue *result);
1290 +static int rangesetRangeMS(RestartData *context, DataValue *argList, int nArgs,
1291 + DataValue *result);
1292 +static int rangesetIncludesPosMS(RestartData *context, DataValue *argList,
1293 + int nArgs, DataValue *result);
1294 +static int rangesetSetColorMS(RestartData *context, DataValue *argList,
1295 + int nArgs, DataValue *result);
1296 +static int rangesetSetUnderlineMS(RestartData *context, DataValue *argList,
1297 + int nArgs, DataValue *result);
1298 +static int rangesetSetNameMS(RestartData *context, DataValue *argList,
1299 + int nArgs, DataValue *result);
1300 +static int rangesetSetModeMS(RestartData *context, DataValue *argList,
1301 + int nArgs, DataValue *result);
1303 static int fillPatternResult(DataValue *result, char **errMsg, WindowInfo *window,
1304 char *patternName, Boolean preallocatedPatternName, Boolean includeName,
1305 char *styleName, int bufferPos);
1306 -static int getPatternByNameMS(WindowInfo *window, DataValue *argList, int nArgs,
1307 - DataValue *result, char **errMsg);
1308 -static int getPatternAtPosMS(WindowInfo *window, DataValue *argList, int nArgs,
1309 - DataValue *result, char **errMsg);
1310 +static int getPatternByNameMS(RestartData *context, DataValue *argList, int nArgs,
1311 + DataValue *result);
1312 +static int getPatternAtPosMS(RestartData *context, DataValue *argList, int nArgs,
1313 + DataValue *result);
1315 static int fillStyleResult(DataValue *result, char **errMsg,
1316 WindowInfo *window, char *styleName, Boolean preallocatedStyleName,
1317 Boolean includeName, int patCode, int bufferPos);
1318 -static int getStyleByNameMS(WindowInfo *window, DataValue *argList, int nArgs,
1319 - DataValue *result, char **errMsg);
1320 -static int getStyleAtPosMS(WindowInfo *window, DataValue *argList, int nArgs,
1321 - DataValue *result, char **errMsg);
1322 -static int filenameDialogMS(WindowInfo* window, DataValue* argList, int nArgs,
1323 - DataValue* result, char** errMsg);
1324 -static int callMS(WindowInfo *window, DataValue *argList,
1325 - int nArgs, DataValue *result, char **errMsg);
1326 -static int setWindowTitleMS(WindowInfo *window, DataValue *argList,
1327 - int nArgs, DataValue *result, char **errMsg);
1328 +static int getStyleByNameMS(RestartData *context, DataValue *argList, int nArgs,
1329 + DataValue *result);
1330 +static int getStyleAtPosMS(RestartData *context, DataValue *argList, int nArgs,
1331 + DataValue *result);
1332 +static int filenameDialogMS(RestartData *context, DataValue *argList, int nArgs,
1333 + DataValue *result);
1334 +static int callMS(RestartData *context, DataValue *argList, int nArgs,
1335 + DataValue *result);
1336 +static int setWindowTitleMS(RestartData *context, DataValue *argList, int nArgs,
1337 + DataValue *result);
1339 /* Pattern Match Feature */
1340 -static int getMatchingMS(WindowInfo *window, DataValue *argList, int nArgs,
1341 - DataValue *result, char **errMsg);
1342 +static int getMatchingMS(RestartData *context, DataValue *argList, int nArgs,
1343 + DataValue *result);
1345 -static int dictinsertMS(WindowInfo *window, DataValue *argList, int nArgs,
1346 - DataValue *result, char **errMsg);
1347 -static int dictcompleteMS(WindowInfo *window, DataValue *argList, int nArgs,
1348 - DataValue *result, char **errMsg);
1349 -static int dictsaveMS(WindowInfo *window, DataValue *argList, int nArgs,
1350 - DataValue *result, char **errMsg);
1351 -static int dictappendMS(WindowInfo *window, DataValue *argList, int nArgs,
1352 - DataValue *result, char **errMsg);
1353 -static int dictiselementMS(WindowInfo *window, DataValue *argList, int nArgs,
1354 - DataValue *result, char **errMsg);
1355 +static int dictinsertMS(RestartData *context, DataValue *argList, int nArgs,
1356 + DataValue *result);
1357 +static int dictcompleteMS(RestartData *context, DataValue *argList, int nArgs,
1358 + DataValue *result);
1359 +static int dictsaveMS(RestartData *context, DataValue *argList, int nArgs,
1360 + DataValue *result);
1361 +static int dictappendMS(RestartData *context, DataValue *argList, int nArgs,
1362 + DataValue *result);
1363 +static int dictiselementMS(RestartData *context, DataValue *argList, int nArgs,
1364 + DataValue *result);
1366 -static int defineMS(WindowInfo *window, DataValue *argList, int nArgs,
1367 - DataValue *result, char **errMsg);
1368 +static int defineMS(RestartData *context, DataValue *argList, int nArgs,
1369 + DataValue *result);
1372 * UL convertPos patch:
1373 * add "to_pos", "to_line", "to_column" macro subroutines
1375 -static int toPosMS(WindowInfo *window, DataValue *argList, int nArgs,
1376 - DataValue *result, char **errMsg);
1377 -static int toLineMS(WindowInfo *window, DataValue *argList, int nArgs,
1378 - DataValue *result, char **errMsg);
1379 -static int toColumnMS(WindowInfo *window, DataValue *argList, int nArgs,
1380 - DataValue *result, char **errMsg);
1382 -static int timerAddMS(WindowInfo *window, DataValue *argList,
1383 - int nArgs, DataValue *result, char **errMsg);
1384 -static int timerRemoveMS(WindowInfo *window, DataValue *argList,
1385 - int nArgs, DataValue *result, char **errMsg);
1386 -static int escapeLiteralMS(WindowInfo *window, DataValue *argList,
1387 - int nArgs, DataValue *result, char **errMsg);
1388 +static int toPosMS(RestartData *context, DataValue *argList, int nArgs,
1389 + DataValue *result);
1390 +static int toLineMS(RestartData *context, DataValue *argList, int nArgs,
1391 + DataValue *result);
1392 +static int toColumnMS(RestartData *context, DataValue *argList, int nArgs,
1393 + DataValue *result);
1395 +static int timerAddMS(RestartData *context, DataValue *argList,
1396 + int nArgs, DataValue *result);
1397 +static int timerRemoveMS(RestartData *context, DataValue *argList,
1398 + int nArgs, DataValue *result);
1399 +static int escapeLiteralMS(RestartData *context, DataValue *argList,
1400 + int nArgs, DataValue *result);
1402 /* Built-in subroutines and variables for the macro language */
1403 static const BuiltInSubrName MacroSubrs[] = {
1404 @@ -1190,7 +1190,7 @@ int MacroWindowCloseActions(WindowInfo *
1405 for (w=WindowList; w!=NULL; w=w->next) {
1406 mcd = (macroCmdInfo *)w->macroCmdData;
1407 if (w == MacroRunWindow() && MacroFocusWindow() == window)
1408 - SetMacroFocusWindow(MacroRunWindow());
1409 + SetMacroFocusWindow(w);
1410 else if (mcd != NULL && mcd->context->focusWindow == window)
1411 mcd->context->focusWindow = mcd->context->runWindow;
1413 @@ -1908,9 +1908,11 @@ static int escapedStringLength(char *str
1414 ** return $args
1415 ** }
1417 -static int argsMS(WindowInfo *window, DataValue *argList, int nArgs,
1418 - DataValue *result, char **errMsg)
1419 +static int argsMS(RestartData *context, DataValue *argList, int nArgs,
1420 + DataValue *result)
1422 + WindowInfo *window = MacroFocusWindow();
1423 + char **errMsg = &context->errMsg;
1424 DataValue *argsArray = &argList[nArgs];
1425 DataValue *argVal;
1426 int argNum;
1427 @@ -1944,9 +1946,11 @@ static int argsMS(WindowInfo *window, Da
1428 ** return i
1429 ** }
1431 -static int nArgsMS(WindowInfo *window, DataValue *argList, int nArgs,
1432 - DataValue *result, char **errMsg)
1433 +static int nArgsMS(RestartData *context, DataValue *argList, int nArgs,
1434 + DataValue *result)
1436 + WindowInfo *window = MacroFocusWindow();
1437 + char **errMsg = &context->errMsg;
1438 DataValue *argsArray = &argList[0];
1439 DataValue val;
1441 @@ -1970,9 +1974,11 @@ static int nArgsMS(WindowInfo *window, D
1443 ** Built-in macro subroutine for getting the length of a string
1445 -static int lengthMS(WindowInfo *window, DataValue *argList, int nArgs,
1446 - DataValue *result, char **errMsg)
1447 +static int lengthMS(RestartData *context, DataValue *argList, int nArgs,
1448 + DataValue *result)
1450 + WindowInfo *window = MacroFocusWindow();
1451 + char **errMsg = &context->errMsg;
1452 char *string, stringStorage[TYPE_INT_STR_SIZE(int)];
1454 if (nArgs != 1)
1455 @@ -1987,9 +1993,11 @@ static int lengthMS(WindowInfo *window,
1457 ** Built-in macro subroutines for min and max
1459 -static int minMS(WindowInfo *window, DataValue *argList, int nArgs,
1460 - DataValue *result, char **errMsg)
1461 +static int minMS(RestartData *context, DataValue *argList, int nArgs,
1462 + DataValue *result)
1464 + WindowInfo *window = MacroFocusWindow();
1465 + char **errMsg = &context->errMsg;
1466 int minVal, value, i;
1468 if (nArgs == 1)
1469 @@ -2005,9 +2013,11 @@ static int minMS(WindowInfo *window, Dat
1470 result->val.n = minVal;
1471 return True;
1473 -static int maxMS(WindowInfo *window, DataValue *argList, int nArgs,
1474 - DataValue *result, char **errMsg)
1475 +static int maxMS(RestartData *context, DataValue *argList, int nArgs,
1476 + DataValue *result)
1478 + WindowInfo *window = MacroFocusWindow();
1479 + char **errMsg = &context->errMsg;
1480 int maxVal, value, i;
1482 if (nArgs == 1)
1483 @@ -2024,9 +2034,11 @@ static int maxMS(WindowInfo *window, Dat
1484 return True;
1487 -static int focusWindowMS(WindowInfo *window, DataValue *argList, int nArgs,
1488 - DataValue *result, char **errMsg)
1489 +static int focusWindowMS(RestartData *context, DataValue *argList, int nArgs,
1490 + DataValue *result)
1492 + WindowInfo *window = MacroFocusWindow();
1493 + char **errMsg = &context->errMsg;
1494 char stringStorage[TYPE_INT_STR_SIZE(int)], *string;
1495 WindowInfo *w;
1496 char fullname[MAXPATHLEN];
1497 @@ -2097,9 +2109,11 @@ static int focusWindowMS(WindowInfo *win
1498 ** Built-in macro subroutine for getting text from the current window's text
1499 ** buffer
1501 -static int getRangeMS(WindowInfo *window, DataValue *argList, int nArgs,
1502 - DataValue *result, char **errMsg)
1503 +static int getRangeMS(RestartData *context, DataValue *argList, int nArgs,
1504 + DataValue *result)
1506 + WindowInfo *window = MacroFocusWindow();
1507 + char **errMsg = &context->errMsg;
1508 int from, to;
1509 textBuffer *buf = window->buffer;
1510 char *rangeText;
1511 @@ -2134,9 +2148,11 @@ static int getRangeMS(WindowInfo *window
1512 ** Built-in macro subroutine for getting a single character at the position
1513 ** given, from the current window
1515 -static int getCharacterMS(WindowInfo *window, DataValue *argList, int nArgs,
1516 - DataValue *result, char **errMsg)
1517 +static int getCharacterMS(RestartData *context, DataValue *argList, int nArgs,
1518 + DataValue *result)
1520 + WindowInfo *window = MacroFocusWindow();
1521 + char **errMsg = &context->errMsg;
1522 int pos;
1523 textBuffer *buf = window->buffer;
1525 @@ -2162,9 +2178,11 @@ static int getCharacterMS(WindowInfo *wi
1526 ** Built-in macro subroutine for replacing text in the current window's text
1527 ** buffer
1529 -static int replaceRangeMS(WindowInfo *window, DataValue *argList, int nArgs,
1530 - DataValue *result, char **errMsg)
1531 +static int replaceRangeMS(RestartData *context, DataValue *argList, int nArgs,
1532 + DataValue *result)
1534 + WindowInfo *window = MacroFocusWindow();
1535 + char **errMsg = &context->errMsg;
1536 int from, to;
1537 char stringStorage[TYPE_INT_STR_SIZE(int)], *string;
1538 textBuffer *buf = window->buffer;
1539 @@ -2212,9 +2230,11 @@ static int replaceRangeMS(WindowInfo *wi
1540 ** Built-in macro subroutine for replacing the primary-selection selected
1541 ** text in the current window's text buffer
1543 -static int replaceSelectionMS(WindowInfo *window, DataValue *argList, int nArgs,
1544 - DataValue *result, char **errMsg)
1545 +static int replaceSelectionMS(RestartData *context, DataValue *argList, int nArgs,
1546 + DataValue *result)
1548 + WindowInfo *window = MacroFocusWindow();
1549 + char **errMsg = &context->errMsg;
1550 char stringStorage[TYPE_INT_STR_SIZE(int)], *string;
1552 /* Validate argument and convert to string */
1553 @@ -2252,9 +2272,11 @@ static int replaceSelectionMS(WindowInfo
1554 ** the primary selection in the current window's text buffer, or in any
1555 ** part of screen if "any" argument is given
1557 -static int getSelectionMS(WindowInfo *window, DataValue *argList, int nArgs,
1558 - DataValue *result, char **errMsg)
1559 +static int getSelectionMS(RestartData *context, DataValue *argList, int nArgs,
1560 + DataValue *result)
1562 + WindowInfo *window = MacroFocusWindow();
1563 + char **errMsg = &context->errMsg;
1564 char *selText;
1566 /* Read argument list to check for "any" keyword, and get the appropriate
1567 @@ -2285,9 +2307,11 @@ static int getSelectionMS(WindowInfo *wi
1568 ** Built-in macro subroutine for determining if implicit conversion of
1569 ** a string to number will succeed or fail
1571 -static int validNumberMS(WindowInfo *window, DataValue *argList, int nArgs,
1572 - DataValue *result, char **errMsg)
1573 +static int validNumberMS(RestartData *context, DataValue *argList, int nArgs,
1574 + DataValue *result)
1576 + WindowInfo *window = MacroFocusWindow();
1577 + char **errMsg = &context->errMsg;
1578 char *string, stringStorage[TYPE_INT_STR_SIZE(int)];
1580 if (nArgs != 1) {
1581 @@ -2306,9 +2330,11 @@ static int validNumberMS(WindowInfo *win
1583 ** Built-in macro subroutine for replacing a substring within another string
1585 -static int replaceSubstringMS(WindowInfo *window, DataValue *argList, int nArgs,
1586 - DataValue *result, char **errMsg)
1587 +static int replaceSubstringMS(RestartData *context, DataValue *argList, int nArgs,
1588 + DataValue *result)
1590 + WindowInfo *window = MacroFocusWindow();
1591 + char **errMsg = &context->errMsg;
1592 int from, to, length, replaceLen, outLen;
1593 char stringStorage[2][TYPE_INT_STR_SIZE(int)], *string, *replStr;
1595 @@ -2345,9 +2371,11 @@ static int replaceSubstringMS(WindowInfo
1596 ** Built-in macro subroutine for getting a substring of a string.
1597 ** Called as substring(string, from [, to])
1599 -static int substringMS(WindowInfo *window, DataValue *argList, int nArgs,
1600 - DataValue *result, char **errMsg)
1601 +static int substringMS(RestartData *context, DataValue *argList, int nArgs,
1602 + DataValue *result)
1604 + WindowInfo *window = MacroFocusWindow();
1605 + char **errMsg = &context->errMsg;
1606 int from, to, length;
1607 char stringStorage[TYPE_INT_STR_SIZE(int)], *string;
1609 @@ -2376,9 +2404,11 @@ static int substringMS(WindowInfo *windo
1610 return True;
1613 -static int toupperMS(WindowInfo *window, DataValue *argList, int nArgs,
1614 - DataValue *result, char **errMsg)
1615 +static int toupperMS(RestartData *context, DataValue *argList, int nArgs,
1616 + DataValue *result)
1618 + WindowInfo *window = MacroFocusWindow();
1619 + char **errMsg = &context->errMsg;
1620 int i, length;
1621 char stringStorage[TYPE_INT_STR_SIZE(int)], *string;
1623 @@ -2397,9 +2427,11 @@ static int toupperMS(WindowInfo *window,
1624 return True;
1627 -static int tolowerMS(WindowInfo *window, DataValue *argList, int nArgs,
1628 - DataValue *result, char **errMsg)
1629 +static int tolowerMS(RestartData *context, DataValue *argList, int nArgs,
1630 + DataValue *result)
1632 + WindowInfo *window = MacroFocusWindow();
1633 + char **errMsg = &context->errMsg;
1634 int i, length;
1635 char stringStorage[TYPE_INT_STR_SIZE(int)], *string;
1637 @@ -2418,9 +2450,11 @@ static int tolowerMS(WindowInfo *window,
1638 return True;
1641 -static int stringToClipboardMS(WindowInfo *window, DataValue *argList, int nArgs,
1642 - DataValue *result, char **errMsg)
1643 +static int stringToClipboardMS(RestartData *context, DataValue *argList, int nArgs,
1644 + DataValue *result)
1646 + WindowInfo *window = MacroFocusWindow();
1647 + char **errMsg = &context->errMsg;
1648 long itemID = 0;
1649 XmString s;
1650 int stat;
1651 @@ -2450,9 +2484,11 @@ static int stringToClipboardMS(WindowInf
1652 return True;
1655 -static int clipboardToStringMS(WindowInfo *window, DataValue *argList, int nArgs,
1656 - DataValue *result, char **errMsg)
1657 +static int clipboardToStringMS(RestartData *context, DataValue *argList, int nArgs,
1658 + DataValue *result)
1660 + WindowInfo *window = MacroFocusWindow();
1661 + char **errMsg = &context->errMsg;
1662 unsigned long length, retLength;
1663 long id = 0;
1665 @@ -2568,9 +2604,11 @@ static char *convFilePathToAbsolute(cons
1666 ** to a full one, using the current window's directory as a base for relative
1667 ** path specifications. It does not check for file/path validity.
1669 -static int fullFileNameMS(WindowInfo *window, DataValue *argList, int nArgs,
1670 - DataValue *result, char **errMsg)
1671 +static int fullFileNameMS(RestartData *context, DataValue *argList, int nArgs,
1672 + DataValue *result)
1674 + WindowInfo *window = MacroFocusWindow();
1675 + char **errMsg = &context->errMsg;
1676 char stringStorage[TYPE_INT_STR_SIZE(int)], *name;
1677 size_t len;
1679 @@ -2603,9 +2641,11 @@ static int fullFileNameMS(WindowInfo *wi
1680 ** file as a string in the subroutine return value. On failure, returns
1681 ** the empty string "" and an 0 $readStatus.
1683 -static int readFileMS(WindowInfo *window, DataValue *argList, int nArgs,
1684 - DataValue *result, char **errMsg)
1685 +static int readFileMS(RestartData *context, DataValue *argList, int nArgs,
1686 + DataValue *result)
1688 + WindowInfo *window = MacroFocusWindow();
1689 + char **errMsg = &context->errMsg;
1690 char stringStorage[TYPE_INT_STR_SIZE(int)], *name;
1691 struct stat statbuf;
1692 FILE *fp;
1693 @@ -2672,15 +2712,19 @@ errorNoClose:
1694 ** to a file named in parameter $2. Returns 1 on successful write, or 0 if
1695 ** unsuccessful.
1697 -static int writeFileMS(WindowInfo *window, DataValue *argList, int nArgs,
1698 - DataValue *result, char **errMsg)
1699 +static int writeFileMS(RestartData *context, DataValue *argList, int nArgs,
1700 + DataValue *result)
1702 + WindowInfo *window = MacroFocusWindow();
1703 + char **errMsg = &context->errMsg;
1704 return writeOrAppendFile(False, window, argList, nArgs, result, errMsg);
1707 -static int appendFileMS(WindowInfo *window, DataValue *argList, int nArgs,
1708 - DataValue *result, char **errMsg)
1709 +static int appendFileMS(RestartData *context, DataValue *argList, int nArgs,
1710 + DataValue *result)
1712 + WindowInfo *window = MacroFocusWindow();
1713 + char **errMsg = &context->errMsg;
1714 return writeOrAppendFile(True, window, argList, nArgs, result, errMsg);
1717 @@ -2735,9 +2779,11 @@ static int writeOrAppendFile(int append,
1718 ** Returns the starting position of the match, or -1 if nothing matched.
1719 ** also returns the ending position of the match in $searchEndPos
1721 -static int searchMS(WindowInfo *window, DataValue *argList, int nArgs,
1722 - DataValue *result, char **errMsg)
1723 +static int searchMS(RestartData *context, DataValue *argList, int nArgs,
1724 + DataValue *result)
1726 + WindowInfo *window = MacroFocusWindow();
1727 + char **errMsg = &context->errMsg;
1728 DataValue newArgList[9];
1730 /* Use the search string routine, by adding the buffer contents as
1731 @@ -2754,7 +2800,7 @@ static int searchMS(WindowInfo *window,
1732 /* copy other arguments to the new argument list */
1733 memcpy(&newArgList[1], argList, nArgs * sizeof(DataValue));
1735 - return searchStringMS(window, newArgList, nArgs+1, result, errMsg);
1736 + return searchStringMS(context, newArgList, nArgs+1, result);
1740 @@ -2768,9 +2814,11 @@ static int searchMS(WindowInfo *window,
1741 ** Returns the starting position of the match, or -1 if nothing matched.
1742 ** also returns the ending position of the match in $searchEndPos
1744 -static int searchStringMS(WindowInfo *window, DataValue *argList, int nArgs,
1745 - DataValue *result, char **errMsg)
1746 +static int searchStringMS(RestartData *context, DataValue *argList, int nArgs,
1747 + DataValue *result)
1749 + WindowInfo *window = MacroFocusWindow();
1750 + char **errMsg = &context->errMsg;
1751 int beginPos, wrap, direction, found = False, foundStart, foundEnd, type;
1752 int skipSearch = False, len;
1753 char stringStorage[2][TYPE_INT_STR_SIZE(int)], *string, *searchStr;
1754 @@ -2835,9 +2883,11 @@ static int searchStringMS(WindowInfo *wi
1755 ** were performed and "copy" was specified, returns a copy of the original
1756 ** string. Otherwise returns an empty string ("").
1758 -static int replaceInStringMS(WindowInfo *window, DataValue *argList, int nArgs,
1759 - DataValue *result, char **errMsg)
1760 +static int replaceInStringMS(RestartData *context, DataValue *argList, int nArgs,
1761 + DataValue *result)
1763 + WindowInfo *window = MacroFocusWindow();
1764 + char **errMsg = &context->errMsg;
1765 char stringStorage[3][TYPE_INT_STR_SIZE(int)], *string, *searchStr, *replaceStr;
1766 char *argStr, *replacedStr;
1767 int searchType = SEARCH_LITERAL, copyStart, copyEnd;
1768 @@ -2929,9 +2979,11 @@ static int readSearchArgs(DataValue *arg
1769 return True;
1772 -static int setCursorPosMS(WindowInfo *window, DataValue *argList, int nArgs,
1773 - DataValue *result, char **errMsg)
1774 +static int setCursorPosMS(RestartData *context, DataValue *argList, int nArgs,
1775 + DataValue *result)
1777 + WindowInfo *window = MacroFocusWindow();
1778 + char **errMsg = &context->errMsg;
1779 int pos;
1781 /* Get argument and convert to int */
1782 @@ -2946,9 +2998,11 @@ static int setCursorPosMS(WindowInfo *wi
1783 return True;
1786 -static int selectMS(WindowInfo *window, DataValue *argList, int nArgs,
1787 - DataValue *result, char **errMsg)
1788 +static int selectMS(RestartData *context, DataValue *argList, int nArgs,
1789 + DataValue *result)
1791 + WindowInfo *window = MacroFocusWindow();
1792 + char **errMsg = &context->errMsg;
1793 int start, end, startTmp;
1795 /* Get arguments and convert to int */
1796 @@ -2976,9 +3030,11 @@ static int selectMS(WindowInfo *window,
1797 return True;
1800 -static int selectRectangleMS(WindowInfo *window, DataValue *argList, int nArgs,
1801 - DataValue *result, char **errMsg)
1802 +static int selectRectangleMS(RestartData *context, DataValue *argList, int nArgs,
1803 + DataValue *result)
1805 + WindowInfo *window = MacroFocusWindow();
1806 + char **errMsg = &context->errMsg;
1807 int start, end, left, right;
1809 /* Get arguments and convert to int */
1810 @@ -3002,9 +3058,11 @@ static int selectRectangleMS(WindowInfo
1812 ** Macro subroutine to ring the bell
1814 -static int beepMS(WindowInfo *window, DataValue *argList, int nArgs,
1815 - DataValue *result, char **errMsg)
1816 +static int beepMS(RestartData *context, DataValue *argList, int nArgs,
1817 + DataValue *result)
1819 + WindowInfo *window = MacroFocusWindow();
1820 + char **errMsg = &context->errMsg;
1821 if (nArgs != 0)
1822 return wrongNArgsErr(errMsg);
1823 XBell(XtDisplay(window->shell), 0);
1824 @@ -3012,9 +3070,11 @@ static int beepMS(WindowInfo *window, Da
1825 return True;
1828 -static int tPrintMS(WindowInfo *window, DataValue *argList, int nArgs,
1829 - DataValue *result, char **errMsg)
1830 +static int tPrintMS(RestartData *context, DataValue *argList, int nArgs,
1831 + DataValue *result)
1833 + WindowInfo *window = MacroFocusWindow();
1834 + char **errMsg = &context->errMsg;
1835 char stringStorage[TYPE_INT_STR_SIZE(int)], *string;
1836 int i;
1838 @@ -3033,9 +3093,11 @@ static int tPrintMS(WindowInfo *window,
1840 ** Built-in macro subroutine for getting the value of an environment variable
1842 -static int getenvMS(WindowInfo *window, DataValue *argList, int nArgs,
1843 - DataValue *result, char **errMsg)
1844 +static int getenvMS(RestartData *context, DataValue *argList, int nArgs,
1845 + DataValue *result)
1847 + WindowInfo *window = MacroFocusWindow();
1848 + char **errMsg = &context->errMsg;
1849 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
1850 char *name;
1851 char *value;
1852 @@ -3057,9 +3119,11 @@ static int getenvMS(WindowInfo *window,
1853 return True;
1856 -static int shellCmdMS(WindowInfo *window, DataValue *argList, int nArgs,
1857 - DataValue *result, char **errMsg)
1858 +static int shellCmdMS(RestartData *context, DataValue *argList, int nArgs,
1859 + DataValue *result)
1861 + WindowInfo *window = MacroFocusWindow();
1862 + char **errMsg = &context->errMsg;
1863 char stringStorage[2][TYPE_INT_STR_SIZE(int)], *cmdString, *inputString = "";
1865 if (nArgs != 1 && nArgs != 2)
1866 @@ -3109,9 +3173,11 @@ void ReturnShellCommandOutput(WindowInfo
1867 ReturnGlobals[SHELL_CMD_STATUS]->value.val.n = status;
1870 -static int dialogMS(WindowInfo *window, DataValue *argList, int nArgs,
1871 - DataValue *result, char **errMsg)
1872 +static int dialogMS(RestartData *context, DataValue *argList, int nArgs,
1873 + DataValue *result)
1875 + WindowInfo *window = MacroFocusWindow();
1876 + char **errMsg = &context->errMsg;
1877 macroCmdInfo *cmdData;
1878 char stringStorage[TYPE_INT_STR_SIZE(int)];
1879 char btnStorage[TYPE_INT_STR_SIZE(int)];
1880 @@ -3286,9 +3352,11 @@ static void dialogEscCB(Widget w, XtPoin
1882 #endif /* LESSTIF_VERSION */
1884 -static int stringDialogMS(WindowInfo *window, DataValue *argList, int nArgs,
1885 - DataValue *result, char **errMsg)
1886 +static int stringDialogMS(RestartData *context, DataValue *argList, int nArgs,
1887 + DataValue *result)
1889 + WindowInfo *window = MacroFocusWindow();
1890 + char **errMsg = &context->errMsg;
1891 macroCmdInfo *cmdData;
1892 char stringStorage[TYPE_INT_STR_SIZE(int)];
1893 char btnStorage[TYPE_INT_STR_SIZE(int)];
1894 @@ -3512,9 +3580,11 @@ static void stringDialogEscCB(Widget w,
1895 ** Does this need to go on IgnoredActions? I don't think so, since
1896 ** showing a calltip may be part of the action you want to learn.
1898 -static int calltipMS(WindowInfo *window, DataValue *argList, int nArgs,
1899 - DataValue *result, char **errMsg)
1900 +static int calltipMS(RestartData *context, DataValue *argList, int nArgs,
1901 + DataValue *result)
1903 + WindowInfo *window = MacroFocusWindow();
1904 + char **errMsg = &context->errMsg;
1905 char stringStorage[TYPE_INT_STR_SIZE(int)], *tipText, *txtArg;
1906 Boolean anchored = False, lookup = True;
1907 int mode = -1, i;
1908 @@ -3605,9 +3675,11 @@ bad_arg:
1910 ** A subroutine to kill the current calltip
1912 -static int killCalltipMS(WindowInfo *window, DataValue *argList, int nArgs,
1913 - DataValue *result, char **errMsg)
1914 +static int killCalltipMS(RestartData *context, DataValue *argList, int nArgs,
1915 + DataValue *result)
1917 + WindowInfo *window = MacroFocusWindow();
1918 + char **errMsg = &context->errMsg;
1919 int calltipID = 0;
1921 if (nArgs > 1) {
1922 @@ -3628,9 +3700,11 @@ static int killCalltipMS(WindowInfo *win
1924 ** highlight_calltip_line(ctID, line)
1926 -static int highlightCTLineMS(WindowInfo *window, DataValue *argList, int nArgs,
1927 - DataValue *result, char **errMsg)
1928 +static int highlightCTLineMS(RestartData *context, DataValue *argList, int nArgs,
1929 + DataValue *result)
1931 + WindowInfo *window = MacroFocusWindow();
1932 + char **errMsg = &context->errMsg;
1933 int calltipID = 0;
1934 int line;
1935 int highlightResult;
1936 @@ -3679,9 +3753,11 @@ static int highlightCTLineMS(WindowInfo
1938 * A subroutine to get the ID of the current calltip, or 0 if there is none.
1940 -static int calltipIDMV(WindowInfo *window, DataValue *argList,
1941 - int nArgs, DataValue *result, char **errMsg)
1942 +static int calltipIDMV(RestartData *context, DataValue *argList, int nArgs,
1943 + DataValue *result)
1945 + WindowInfo *window = MacroFocusWindow();
1946 + char **errMsg = &context->errMsg;
1947 result->tag = INT_TAG;
1948 result->val.n = GetCalltipID(window, 0);
1949 return True;
1950 @@ -3708,9 +3784,11 @@ static int calltipIDMV(WindowInfo *windo
1952 ** Note that defaultName doesn't work on all *tifs. :-(
1954 -static int filenameDialogMS(WindowInfo* window, DataValue* argList, int nArgs,
1955 - DataValue* result, char** errMsg)
1956 +static int filenameDialogMS(RestartData *context, DataValue *argList, int nArgs,
1957 + DataValue *result)
1959 + WindowInfo *window = MacroFocusWindow();
1960 + char **errMsg = &context->errMsg;
1961 char stringStorage[5][TYPE_INT_STR_SIZE(int)];
1962 char filename[MAXPATHLEN + 1];
1963 char* title = "Choose Filename";
1964 @@ -3811,9 +3889,11 @@ static int filenameDialogMS(WindowInfo*
1966 * call(fnname, arg, ...)
1968 -static int callMS(WindowInfo *window, DataValue *argList,
1969 - int nArgs, DataValue *result, char **errMsg)
1970 +static int callMS(RestartData *context, DataValue *argList, int nArgs,
1971 + DataValue *result)
1973 + WindowInfo *window = MacroFocusWindow();
1974 + char **errMsg = &context->errMsg;
1975 Symbol *sym;
1977 if (nArgs < 1) {
1978 @@ -3838,15 +3918,17 @@ static int callMS(WindowInfo *window, Da
1979 return False;
1982 - return OverlayRoutineFromSymbol(sym, nArgs, 1);
1983 + return OverlayRoutineFromSymbol(context, sym, nArgs, 1);
1987 * subr = define(func_name, func_body[, "override"])
1989 -static int defineMS(WindowInfo *window, DataValue *argList, int nArgs,
1990 - DataValue *result, char **errMsg)
1991 +static int defineMS(RestartData *context, DataValue *argList, int nArgs,
1992 + DataValue *result)
1994 + WindowInfo *window = MacroFocusWindow();
1995 + char **errMsg = &context->errMsg;
1996 char stringStorage[3][TYPE_INT_STR_SIZE(int)];
1997 char *name = NULL;
1998 char *body = NULL;
1999 @@ -3940,9 +4022,11 @@ static int defineMS(WindowInfo *window,
2001 * set_window_title(format[, ("text"|"format")])
2003 -static int setWindowTitleMS(WindowInfo *window, DataValue *argList,
2004 - int nArgs, DataValue *result, char **errMsg)
2005 +static int setWindowTitleMS(RestartData *context, DataValue *argList, int nArgs,
2006 + DataValue *result)
2008 + WindowInfo *window = MacroFocusWindow();
2009 + char **errMsg = &context->errMsg;
2010 char stringStorage[2][TYPE_INT_STR_SIZE(int)];
2011 char *fmt = NULL;
2012 char *type = NULL;
2013 @@ -4064,9 +4148,11 @@ out:
2015 * timer_ID = timer_add(macro_name, timeout[, "global"])
2017 -static int timerAddMS(WindowInfo *window, DataValue *argList, int nArgs,
2018 - DataValue *result, char **errMsg)
2019 +static int timerAddMS(RestartData *context, DataValue *argList, int nArgs,
2020 + DataValue *result)
2022 + WindowInfo *window = MacroFocusWindow();
2023 + char **errMsg = &context->errMsg;
2024 int timeout;
2025 char stringStorage[2][TYPE_INT_STR_SIZE(int)];
2026 char *name = NULL;
2027 @@ -4132,9 +4218,11 @@ static int timerAddMS(WindowInfo *window
2029 * timer_remove(timer_ID)
2031 -static int timerRemoveMS(WindowInfo *window, DataValue *argList, int nArgs,
2032 - DataValue *result, char **errMsg)
2033 +static int timerRemoveMS(RestartData *context, DataValue *argList, int nArgs,
2034 + DataValue *result)
2036 + WindowInfo *window = MacroFocusWindow();
2037 + char **errMsg = &context->errMsg;
2038 int timerid;
2039 XtIntervalId id;
2040 TimerProcData *data, **s;
2041 @@ -4175,9 +4263,11 @@ static int timerRemoveMS(WindowInfo *win
2043 * escaped_string = escape_literal(string)
2045 -static int escapeLiteralMS(WindowInfo *window, DataValue *argList, int nArgs,
2046 - DataValue *result, char **errMsg)
2047 +static int escapeLiteralMS(RestartData *context, DataValue *argList, int nArgs,
2048 + DataValue *result)
2050 + WindowInfo *window = MacroFocusWindow();
2051 + char **errMsg = &context->errMsg;
2052 static const char chars_to_escape[] = "()[]<>{}.\\|^$*+?&";
2053 char stringStorage[TYPE_INT_STR_SIZE(int)];
2054 char *string = NULL;
2055 @@ -4221,9 +4311,11 @@ static int escapeLiteralMS(WindowInfo *w
2058 /* T Balinski */
2059 -static int listDialogMS(WindowInfo *window, DataValue *argList, int nArgs,
2060 - DataValue *result, char **errMsg)
2061 +static int listDialogMS(RestartData *context, DataValue *argList, int nArgs,
2062 + DataValue *result)
2064 + WindowInfo *window = MacroFocusWindow();
2065 + char **errMsg = &context->errMsg;
2066 macroCmdInfo *cmdData;
2067 char stringStorage[TYPE_INT_STR_SIZE(int)];
2068 char textStorage[TYPE_INT_STR_SIZE(int)];
2069 @@ -4568,9 +4660,11 @@ static void listDialogEscCB(Widget w, Xt
2070 #endif /* LESSTIF_VERSION */
2073 -static int stringCompareMS(WindowInfo *window, DataValue *argList, int nArgs,
2074 - DataValue *result, char **errMsg)
2075 +static int stringCompareMS(RestartData *context, DataValue *argList, int nArgs,
2076 + DataValue *result)
2078 + WindowInfo *window = MacroFocusWindow();
2079 + char **errMsg = &context->errMsg;
2080 char stringStorage[3][TYPE_INT_STR_SIZE(int)];
2081 char *leftStr, *rightStr, *argStr;
2082 int considerCase = True;
2083 @@ -4644,9 +4738,11 @@ static int stringCompareMS(WindowInfo *w
2084 ** array sub-scripts (unless "lastnotnull" is present)
2087 -static int splitMS(WindowInfo *window, DataValue *argList, int nArgs,
2088 - DataValue *result, char **errMsg)
2089 +static int splitMS(RestartData *context, DataValue *argList, int nArgs,
2090 + DataValue *result)
2092 + WindowInfo *window = MacroFocusWindow();
2093 + char **errMsg = &context->errMsg;
2094 char stringStorage[3][TYPE_INT_STR_SIZE(int)];
2095 char *sourceStr, *splitStr, *typeSplitStr;
2096 int searchType, beginPos, foundStart, foundEnd, strLength, lastEnd;
2097 @@ -4835,9 +4931,11 @@ static int splitMS(WindowInfo *window, D
2098 ** end will be one beyond the last valid integer index of a contiguous sequence
2099 ** starting at start.
2101 -static int joinMS(WindowInfo *window, DataValue *argList, int nArgs,
2102 - DataValue *result, char **errMsg)
2103 +static int joinMS(RestartData *context, DataValue *argList, int nArgs,
2104 + DataValue *result)
2106 + WindowInfo *window = MacroFocusWindow();
2107 + char **errMsg = &context->errMsg;
2108 char stringStorage[TYPE_INT_STR_SIZE(int)];
2109 char *sepStr;
2110 int start, end, index;
2111 @@ -4950,8 +5048,8 @@ static int joinMS(WindowInfo *window, Da
2112 ** will be cleared, turning off backlighting.
2114 /* DISABLED for 5.4
2115 -static int setBacklightStringMS(WindowInfo *window, DataValue *argList,
2116 - int nArgs, DataValue *result, char **errMsg)
2117 +static int setBacklightStringMS(RestartData *context, DataValue *argList,
2118 + int nArgs, DataValue *result)
2120 char *backlightString;
2122 @@ -4977,17 +5075,21 @@ static int setBacklightStringMS(WindowIn
2123 return True;
2124 } */
2126 -static int cursorMV(WindowInfo *window, DataValue *argList, int nArgs,
2127 - DataValue *result, char **errMsg)
2128 +static int cursorMV(RestartData *context, DataValue *argList, int nArgs,
2129 + DataValue *result)
2131 + WindowInfo *window = MacroFocusWindow();
2132 + char **errMsg = &context->errMsg;
2133 result->tag = INT_TAG;
2134 result->val.n = TextGetCursorPos(window->lastFocus);
2135 return True;
2138 -static int lineMV(WindowInfo *window, DataValue *argList, int nArgs,
2139 - DataValue *result, char **errMsg)
2140 +static int lineMV(RestartData *context, DataValue *argList, int nArgs,
2141 + DataValue *result)
2143 + WindowInfo *window = MacroFocusWindow();
2144 + char **errMsg = &context->errMsg;
2145 int line, cursorPos, colNum;
2147 result->tag = INT_TAG;
2148 @@ -4998,9 +5100,11 @@ static int lineMV(WindowInfo *window, Da
2149 return True;
2152 -static int columnMV(WindowInfo *window, DataValue *argList, int nArgs,
2153 - DataValue *result, char **errMsg)
2154 +static int columnMV(RestartData *context, DataValue *argList, int nArgs,
2155 + DataValue *result)
2157 + WindowInfo *window = MacroFocusWindow();
2158 + char **errMsg = &context->errMsg;
2159 textBuffer *buf = window->buffer;
2160 int cursorPos;
2162 @@ -5011,51 +5115,63 @@ static int columnMV(WindowInfo *window,
2163 return True;
2166 -static int fileNameMV(WindowInfo *window, DataValue *argList, int nArgs,
2167 - DataValue *result, char **errMsg)
2168 +static int fileNameMV(RestartData *context, DataValue *argList, int nArgs,
2169 + DataValue *result)
2171 + WindowInfo *window = MacroFocusWindow();
2172 + char **errMsg = &context->errMsg;
2173 result->tag = STRING_TAG;
2174 AllocNStringCpy(&result->val.str, window->filename);
2175 return True;
2178 -static int filePathMV(WindowInfo *window, DataValue *argList, int nArgs,
2179 - DataValue *result, char **errMsg)
2180 +static int filePathMV(RestartData *context, DataValue *argList, int nArgs,
2181 + DataValue *result)
2183 + WindowInfo *window = MacroFocusWindow();
2184 + char **errMsg = &context->errMsg;
2185 result->tag = STRING_TAG;
2186 AllocNStringCpy(&result->val.str, window->path);
2187 return True;
2190 -static int lengthMV(WindowInfo *window, DataValue *argList, int nArgs,
2191 - DataValue *result, char **errMsg)
2192 +static int lengthMV(RestartData *context, DataValue *argList, int nArgs,
2193 + DataValue *result)
2195 + WindowInfo *window = MacroFocusWindow();
2196 + char **errMsg = &context->errMsg;
2197 result->tag = INT_TAG;
2198 result->val.n = window->buffer->length;
2199 return True;
2202 -static int selectionStartMV(WindowInfo *window, DataValue *argList, int nArgs,
2203 - DataValue *result, char **errMsg)
2204 +static int selectionStartMV(RestartData *context, DataValue *argList, int nArgs,
2205 + DataValue *result)
2207 + WindowInfo *window = MacroFocusWindow();
2208 + char **errMsg = &context->errMsg;
2209 result->tag = INT_TAG;
2210 result->val.n = window->buffer->primary.selected ?
2211 window->buffer->primary.start : -1;
2212 return True;
2215 -static int selectionEndMV(WindowInfo *window, DataValue *argList, int nArgs,
2216 - DataValue *result, char **errMsg)
2217 +static int selectionEndMV(RestartData *context, DataValue *argList, int nArgs,
2218 + DataValue *result)
2220 + WindowInfo *window = MacroFocusWindow();
2221 + char **errMsg = &context->errMsg;
2222 result->tag = INT_TAG;
2223 result->val.n = window->buffer->primary.selected ?
2224 window->buffer->primary.end : -1;
2225 return True;
2228 -static int selectionLeftMV(WindowInfo *window, DataValue *argList, int nArgs,
2229 - DataValue *result, char **errMsg)
2230 +static int selectionLeftMV(RestartData *context, DataValue *argList, int nArgs,
2231 + DataValue *result)
2233 + WindowInfo *window = MacroFocusWindow();
2234 + char **errMsg = &context->errMsg;
2235 selection *sel = &window->buffer->primary;
2237 result->tag = INT_TAG;
2238 @@ -5063,9 +5179,11 @@ static int selectionLeftMV(WindowInfo *w
2239 return True;
2242 -static int selectionRightMV(WindowInfo *window, DataValue *argList, int nArgs,
2243 - DataValue *result, char **errMsg)
2244 +static int selectionRightMV(RestartData *context, DataValue *argList, int nArgs,
2245 + DataValue *result)
2247 + WindowInfo *window = MacroFocusWindow();
2248 + char **errMsg = &context->errMsg;
2249 selection *sel = &window->buffer->primary;
2251 result->tag = INT_TAG;
2252 @@ -5073,9 +5191,11 @@ static int selectionRightMV(WindowInfo *
2253 return True;
2256 -static int wrapMarginMV(WindowInfo *window, DataValue *argList, int nArgs,
2257 - DataValue *result, char **errMsg)
2258 +static int wrapMarginMV(RestartData *context, DataValue *argList, int nArgs,
2259 + DataValue *result)
2261 + WindowInfo *window = MacroFocusWindow();
2262 + char **errMsg = &context->errMsg;
2263 int margin, nCols;
2265 XtVaGetValues(window->textArea, textNcolumns, &nCols,
2266 @@ -5085,33 +5205,41 @@ static int wrapMarginMV(WindowInfo *wind
2267 return True;
2270 -static int statisticsLineMV(WindowInfo *window, DataValue *argList, int nArgs,
2271 - DataValue *result, char **errMsg)
2272 +static int statisticsLineMV(RestartData *context, DataValue *argList, int nArgs,
2273 + DataValue *result)
2275 + WindowInfo *window = MacroFocusWindow();
2276 + char **errMsg = &context->errMsg;
2277 result->tag = INT_TAG;
2278 result->val.n = window->showStats ? 1 : 0;
2279 return True;
2282 -static int incSearchLineMV(WindowInfo *window, DataValue *argList, int nArgs,
2283 - DataValue *result, char **errMsg)
2284 +static int incSearchLineMV(RestartData *context, DataValue *argList, int nArgs,
2285 + DataValue *result)
2287 + WindowInfo *window = MacroFocusWindow();
2288 + char **errMsg = &context->errMsg;
2289 result->tag = INT_TAG;
2290 result->val.n = window->showISearchLine ? 1 : 0;
2291 return True;
2294 -static int showLineNumbersMV(WindowInfo *window, DataValue *argList, int nArgs,
2295 - DataValue *result, char **errMsg)
2296 +static int showLineNumbersMV(RestartData *context, DataValue *argList, int nArgs,
2297 + DataValue *result)
2299 + WindowInfo *window = MacroFocusWindow();
2300 + char **errMsg = &context->errMsg;
2301 result->tag = INT_TAG;
2302 result->val.n = window->showLineNumbers ? 1 : 0;
2303 return True;
2306 -static int autoIndentMV(WindowInfo *window, DataValue *argList, int nArgs,
2307 - DataValue *result, char **errMsg)
2308 +static int autoIndentMV(RestartData *context, DataValue *argList, int nArgs,
2309 + DataValue *result)
2311 + WindowInfo *window = MacroFocusWindow();
2312 + char **errMsg = &context->errMsg;
2313 char *res = NULL;
2315 switch (window->indentStyle) {
2316 @@ -5135,9 +5263,11 @@ static int autoIndentMV(WindowInfo *wind
2317 return True;
2320 -static int wrapTextMV(WindowInfo *window, DataValue *argList, int nArgs,
2321 - DataValue *result, char **errMsg)
2322 +static int wrapTextMV(RestartData *context, DataValue *argList, int nArgs,
2323 + DataValue *result)
2325 + WindowInfo *window = MacroFocusWindow();
2326 + char **errMsg = &context->errMsg;
2327 char *res = NULL;
2329 switch (window->wrapMode) {
2330 @@ -5161,33 +5291,41 @@ static int wrapTextMV(WindowInfo *window
2331 return True;
2334 -static int highlightSyntaxMV(WindowInfo *window, DataValue *argList, int nArgs,
2335 - DataValue *result, char **errMsg)
2336 +static int highlightSyntaxMV(RestartData *context, DataValue *argList, int nArgs,
2337 + DataValue *result)
2339 + WindowInfo *window = MacroFocusWindow();
2340 + char **errMsg = &context->errMsg;
2341 result->tag = INT_TAG;
2342 result->val.n = window->highlightSyntax ? 1 : 0;
2343 return True;
2346 -static int makeBackupCopyMV(WindowInfo *window, DataValue *argList, int nArgs,
2347 - DataValue *result, char **errMsg)
2348 +static int makeBackupCopyMV(RestartData *context, DataValue *argList, int nArgs,
2349 + DataValue *result)
2351 + WindowInfo *window = MacroFocusWindow();
2352 + char **errMsg = &context->errMsg;
2353 result->tag = INT_TAG;
2354 result->val.n = window->saveOldVersion ? 1 : 0;
2355 return True;
2358 -static int incBackupMV(WindowInfo *window, DataValue *argList, int nArgs,
2359 - DataValue *result, char **errMsg)
2360 +static int incBackupMV(RestartData *context, DataValue *argList, int nArgs,
2361 + DataValue *result)
2363 + WindowInfo *window = MacroFocusWindow();
2364 + char **errMsg = &context->errMsg;
2365 result->tag = INT_TAG;
2366 result->val.n = window->autoSave ? 1 : 0;
2367 return True;
2370 -static int showMatchingMV(WindowInfo *window, DataValue *argList, int nArgs,
2371 - DataValue *result, char **errMsg)
2372 +static int showMatchingMV(RestartData *context, DataValue *argList, int nArgs,
2373 + DataValue *result)
2375 + WindowInfo *window = MacroFocusWindow();
2376 + char **errMsg = &context->errMsg;
2377 char *res = NULL;
2379 switch (window->showMatchingStyle) {
2380 @@ -5211,33 +5349,41 @@ static int showMatchingMV(WindowInfo *wi
2381 return True;
2384 -static int overTypeModeMV(WindowInfo *window, DataValue *argList, int nArgs,
2385 - DataValue *result, char **errMsg)
2386 +static int overTypeModeMV(RestartData *context, DataValue *argList, int nArgs,
2387 + DataValue *result)
2389 + WindowInfo *window = MacroFocusWindow();
2390 + char **errMsg = &context->errMsg;
2391 result->tag = INT_TAG;
2392 result->val.n = window->overstrike ? 1 : 0;
2393 return True;
2396 -static int readOnlyMV(WindowInfo *window, DataValue *argList, int nArgs,
2397 - DataValue *result, char **errMsg)
2398 +static int readOnlyMV(RestartData *context, DataValue *argList, int nArgs,
2399 + DataValue *result)
2401 + WindowInfo *window = MacroFocusWindow();
2402 + char **errMsg = &context->errMsg;
2403 result->tag = INT_TAG;
2404 result->val.n = (IS_ANY_LOCKED(window->lockReasons)) ? 1 : 0;
2405 return True;
2408 -static int lockedMV(WindowInfo *window, DataValue *argList, int nArgs,
2409 - DataValue *result, char **errMsg)
2410 +static int lockedMV(RestartData *context, DataValue *argList, int nArgs,
2411 + DataValue *result)
2413 + WindowInfo *window = MacroFocusWindow();
2414 + char **errMsg = &context->errMsg;
2415 result->tag = INT_TAG;
2416 result->val.n = (IS_USER_LOCKED(window->lockReasons)) ? 1 : 0;
2417 return True;
2420 -static int fileFormatMV(WindowInfo *window, DataValue *argList, int nArgs,
2421 - DataValue *result, char **errMsg)
2422 +static int fileFormatMV(RestartData *context, DataValue *argList, int nArgs,
2423 + DataValue *result)
2425 + WindowInfo *window = MacroFocusWindow();
2426 + char **errMsg = &context->errMsg;
2427 char *res = NULL;
2429 switch (window->fileFormat) {
2430 @@ -5260,130 +5406,162 @@ static int fileFormatMV(WindowInfo *wind
2431 return True;
2434 -static int fontNameMV(WindowInfo *window, DataValue *argList, int nArgs,
2435 - DataValue *result, char **errMsg)
2436 +static int fontNameMV(RestartData *context, DataValue *argList, int nArgs,
2437 + DataValue *result)
2439 + WindowInfo *window = MacroFocusWindow();
2440 + char **errMsg = &context->errMsg;
2441 result->tag = STRING_TAG;
2442 AllocNStringCpy(&result->val.str, window->fontName);
2443 return True;
2446 -static int fontNameItalicMV(WindowInfo *window, DataValue *argList, int nArgs,
2447 - DataValue *result, char **errMsg)
2448 +static int fontNameItalicMV(RestartData *context, DataValue *argList, int nArgs,
2449 + DataValue *result)
2451 + WindowInfo *window = MacroFocusWindow();
2452 + char **errMsg = &context->errMsg;
2453 result->tag = STRING_TAG;
2454 AllocNStringCpy(&result->val.str, window->italicFontName);
2455 return True;
2458 -static int fontNameBoldMV(WindowInfo *window, DataValue *argList, int nArgs,
2459 - DataValue *result, char **errMsg)
2460 +static int fontNameBoldMV(RestartData *context, DataValue *argList, int nArgs,
2461 + DataValue *result)
2463 + WindowInfo *window = MacroFocusWindow();
2464 + char **errMsg = &context->errMsg;
2465 result->tag = STRING_TAG;
2466 AllocNStringCpy(&result->val.str, window->boldFontName);
2467 return True;
2470 -static int fontNameBoldItalicMV(WindowInfo *window, DataValue *argList, int nArgs,
2471 - DataValue *result, char **errMsg)
2472 +static int fontNameBoldItalicMV(RestartData *context, DataValue *argList, int nArgs,
2473 + DataValue *result)
2475 + WindowInfo *window = MacroFocusWindow();
2476 + char **errMsg = &context->errMsg;
2477 result->tag = STRING_TAG;
2478 AllocNStringCpy(&result->val.str, window->boldItalicFontName);
2479 return True;
2482 -static int subscriptSepMV(WindowInfo *window, DataValue *argList, int nArgs,
2483 - DataValue *result, char **errMsg)
2484 +static int subscriptSepMV(RestartData *context, DataValue *argList, int nArgs,
2485 + DataValue *result)
2487 + WindowInfo *window = MacroFocusWindow();
2488 + char **errMsg = &context->errMsg;
2489 result->tag = STRING_TAG;
2490 result->val.str.rep = PERM_ALLOC_STR(ARRAY_DIM_SEP);
2491 result->val.str.len = strlen(result->val.str.rep);
2492 return True;
2495 -static int minFontWidthMV(WindowInfo *window, DataValue *argList, int nArgs,
2496 - DataValue *result, char **errMsg)
2497 +static int minFontWidthMV(RestartData *context, DataValue *argList, int nArgs,
2498 + DataValue *result)
2500 + WindowInfo *window = MacroFocusWindow();
2501 + char **errMsg = &context->errMsg;
2502 result->tag = INT_TAG;
2503 result->val.n = TextGetMinFontWidth(window->textArea, window->highlightSyntax);
2504 return True;
2507 -static int maxFontWidthMV(WindowInfo *window, DataValue *argList, int nArgs,
2508 - DataValue *result, char **errMsg)
2509 +static int maxFontWidthMV(RestartData *context, DataValue *argList, int nArgs,
2510 + DataValue *result)
2512 + WindowInfo *window = MacroFocusWindow();
2513 + char **errMsg = &context->errMsg;
2514 result->tag = INT_TAG;
2515 result->val.n = TextGetMaxFontWidth(window->textArea, window->highlightSyntax);
2516 return True;
2519 -static int topLineMV(WindowInfo *window, DataValue *argList, int nArgs,
2520 - DataValue *result, char **errMsg)
2521 +static int topLineMV(RestartData *context, DataValue *argList, int nArgs,
2522 + DataValue *result)
2524 + WindowInfo *window = MacroFocusWindow();
2525 + char **errMsg = &context->errMsg;
2526 result->tag = INT_TAG;
2527 result->val.n = TextFirstVisibleLine(window->lastFocus);
2528 return True;
2531 -static int numDisplayLinesMV(WindowInfo *window, DataValue *argList, int nArgs,
2532 - DataValue *result, char **errMsg)
2533 +static int numDisplayLinesMV(RestartData *context, DataValue *argList, int nArgs,
2534 + DataValue *result)
2536 + WindowInfo *window = MacroFocusWindow();
2537 + char **errMsg = &context->errMsg;
2538 result->tag = INT_TAG;
2539 result->val.n = TextNumVisibleLines(window->lastFocus);
2540 return True;
2543 -static int displayWidthMV(WindowInfo *window, DataValue *argList, int nArgs,
2544 - DataValue *result, char **errMsg)
2545 +static int displayWidthMV(RestartData *context, DataValue *argList, int nArgs,
2546 + DataValue *result)
2548 + WindowInfo *window = MacroFocusWindow();
2549 + char **errMsg = &context->errMsg;
2550 result->tag = INT_TAG;
2551 result->val.n = TextVisibleWidth(window->lastFocus);
2552 return True;
2555 -static int activePaneMV(WindowInfo *window, DataValue *argList, int nArgs,
2556 - DataValue *result, char **errMsg)
2557 +static int activePaneMV(RestartData *context, DataValue *argList, int nArgs,
2558 + DataValue *result)
2560 + WindowInfo *window = MacroFocusWindow();
2561 + char **errMsg = &context->errMsg;
2562 result->tag = INT_TAG;
2563 result->val.n = WidgetToPaneIndex(window, window->lastFocus) + 1;
2564 return True;
2567 -static int nPanesMV(WindowInfo *window, DataValue *argList, int nArgs,
2568 - DataValue *result, char **errMsg)
2569 +static int nPanesMV(RestartData *context, DataValue *argList, int nArgs,
2570 + DataValue *result)
2572 + WindowInfo *window = MacroFocusWindow();
2573 + char **errMsg = &context->errMsg;
2574 result->tag = INT_TAG;
2575 result->val.n = window->nPanes + 1;
2576 return True;
2579 -static int emptyArrayMV(WindowInfo *window, DataValue *argList, int nArgs,
2580 - DataValue *result, char **errMsg)
2581 +static int emptyArrayMV(RestartData *context, DataValue *argList, int nArgs,
2582 + DataValue *result)
2584 + WindowInfo *window = MacroFocusWindow();
2585 + char **errMsg = &context->errMsg;
2586 result->tag = ARRAY_TAG;
2587 result->val.arrayPtr = NULL;
2588 return True;
2591 -static int serverNameMV(WindowInfo *window, DataValue *argList, int nArgs,
2592 - DataValue *result, char **errMsg)
2593 +static int serverNameMV(RestartData *context, DataValue *argList, int nArgs,
2594 + DataValue *result)
2596 + WindowInfo *window = MacroFocusWindow();
2597 + char **errMsg = &context->errMsg;
2598 result->tag = STRING_TAG;
2599 AllocNStringCpy(&result->val.str, GetPrefServerName());
2600 return True;
2603 -static int tabDistMV(WindowInfo *window, DataValue *argList, int nArgs,
2604 - DataValue *result, char **errMsg)
2605 +static int tabDistMV(RestartData *context, DataValue *argList, int nArgs,
2606 + DataValue *result)
2608 + WindowInfo *window = MacroFocusWindow();
2609 + char **errMsg = &context->errMsg;
2610 result->tag = INT_TAG;
2611 result->val.n = window->buffer->tabDist;
2612 return True;
2615 -static int emTabDistMV(WindowInfo *window, DataValue *argList, int nArgs,
2616 - DataValue *result, char **errMsg)
2617 +static int emTabDistMV(RestartData *context, DataValue *argList, int nArgs,
2618 + DataValue *result)
2620 + WindowInfo *window = MacroFocusWindow();
2621 + char **errMsg = &context->errMsg;
2622 int dist;
2624 XtVaGetValues(window->textArea, textNemulateTabs, &dist, NULL);
2625 @@ -5392,25 +5570,31 @@ static int emTabDistMV(WindowInfo *windo
2626 return True;
2629 -static int useTabsMV(WindowInfo *window, DataValue *argList, int nArgs,
2630 - DataValue *result, char **errMsg)
2631 +static int useTabsMV(RestartData *context, DataValue *argList, int nArgs,
2632 + DataValue *result)
2634 + WindowInfo *window = MacroFocusWindow();
2635 + char **errMsg = &context->errMsg;
2636 result->tag = INT_TAG;
2637 result->val.n = window->buffer->useTabs;
2638 return True;
2641 -static int modifiedMV(WindowInfo *window, DataValue *argList, int nArgs,
2642 - DataValue *result, char **errMsg)
2643 +static int modifiedMV(RestartData *context, DataValue *argList, int nArgs,
2644 + DataValue *result)
2646 + WindowInfo *window = MacroFocusWindow();
2647 + char **errMsg = &context->errMsg;
2648 result->tag = INT_TAG;
2649 result->val.n = window->fileChanged;
2650 return True;
2653 -static int languageModeMV(WindowInfo *window, DataValue *argList, int nArgs,
2654 - DataValue *result, char **errMsg)
2655 +static int languageModeMV(RestartData *context, DataValue *argList, int nArgs,
2656 + DataValue *result)
2658 + WindowInfo *window = MacroFocusWindow();
2659 + char **errMsg = &context->errMsg;
2660 char *lmName = LanguageModeName(window->languageMode);
2662 if (lmName == NULL)
2663 @@ -5421,8 +5605,8 @@ static int languageModeMV(WindowInfo *wi
2666 /* DISABLED for 5.4
2667 -static int backlightStringMV(WindowInfo *window, DataValue *argList,
2668 - int nArgs, DataValue *result, char **errMsg)
2669 +static int backlightStringMV(RestartData *context, DataValue *argList,
2670 + int nArgs, DataValue *result)
2672 char *backlightString = window->backlightCharTypes;
2674 @@ -5438,9 +5622,11 @@ static int backlightStringMV(WindowInfo
2676 ** Range set macro variables and functions
2678 -static int rangesetListMV(WindowInfo *window, DataValue *argList, int nArgs,
2679 - DataValue *result, char **errMsg)
2680 +static int rangesetListMV(RestartData *context, DataValue *argList, int nArgs,
2681 + DataValue *result)
2683 + WindowInfo *window = MacroFocusWindow();
2684 + char **errMsg = &context->errMsg;
2685 RangesetTable *rangesetTable = window->buffer->rangesetTable;
2686 unsigned char *rangesetList;
2687 char *allocIndexStr;
2688 @@ -5484,9 +5670,11 @@ static int rangesetListMV(WindowInfo *wi
2689 ** different point revisions. This is done because the macro interface
2690 ** does not change for the same version.
2692 -static int versionMV(WindowInfo* window, DataValue* argList, int nArgs,
2693 - DataValue* result, char** errMsg)
2694 +static int versionMV(RestartData *context, DataValue *argList, int nArgs,
2695 + DataValue *result)
2697 + WindowInfo *window = MacroFocusWindow();
2698 + char **errMsg = &context->errMsg;
2699 static unsigned version = NEDIT_VERSION * 1000 + NEDIT_REVISION;
2701 result->tag = INT_TAG;
2702 @@ -5500,9 +5688,11 @@ static int versionMV(WindowInfo* window,
2703 ** default of ~/.nedit or $HOME. (See the online documentation for details
2704 ** about the algorithm.)
2706 -static int neditHomeMV(WindowInfo *window, DataValue *argList, int nArgs,
2707 - DataValue *result, char **errMsg)
2708 +static int neditHomeMV(RestartData *context, DataValue *argList, int nArgs,
2709 + DataValue *result)
2711 + WindowInfo *window = MacroFocusWindow();
2712 + char **errMsg = &context->errMsg;
2713 const char *neditRCName = GetRCFileName(NEDIT_RC);
2714 char neditHome[MAXPATHLEN];
2716 @@ -5519,9 +5709,11 @@ static int neditHomeMV(WindowInfo *windo
2718 ** Returns the transient status of the current window
2720 -static int transientMV(WindowInfo *window, DataValue *argList, int nArgs,
2721 - DataValue *result, char **errMsg)
2722 +static int transientMV(RestartData *context, DataValue *argList, int nArgs,
2723 + DataValue *result)
2725 + WindowInfo *window = MacroFocusWindow();
2726 + char **errMsg = &context->errMsg;
2727 result->tag = INT_TAG;
2728 result->val.n = !!window->transient;
2729 return True;
2730 @@ -5535,9 +5727,11 @@ static int transientMV(WindowInfo *windo
2731 ** If called with no arguments, returns a single rangeset label (not an array),
2732 ** or an empty string if there are no rangesets available.
2734 -static int rangesetCreateMS(WindowInfo *window, DataValue *argList, int nArgs,
2735 - DataValue *result, char **errMsg)
2736 +static int rangesetCreateMS(RestartData *context, DataValue *argList, int nArgs,
2737 + DataValue *result)
2739 + WindowInfo *window = MacroFocusWindow();
2740 + char **errMsg = &context->errMsg;
2741 int label;
2742 int i, nRangesetsRequired;
2743 DataValue element;
2744 @@ -5591,9 +5785,11 @@ static int rangesetCreateMS(WindowInfo *
2746 ** Built-in macro subroutine for forgetting a range set.
2748 -static int rangesetDestroyMS(WindowInfo *window, DataValue *argList, int nArgs,
2749 - DataValue *result, char **errMsg)
2750 +static int rangesetDestroyMS(RestartData *context, DataValue *argList, int nArgs,
2751 + DataValue *result)
2753 + WindowInfo *window = MacroFocusWindow();
2754 + char **errMsg = &context->errMsg;
2755 RangesetTable *rangesetTable = window->buffer->rangesetTable;
2756 DataValue *array;
2757 DataValue element;
2758 @@ -5654,9 +5850,11 @@ static int rangesetDestroyMS(WindowInfo
2759 ** Arguments are $1: range set name.
2760 ** return value is an array indexed 0 to n, with the rangeset labels as values;
2762 -static int rangesetGetByNameMS(WindowInfo *window, DataValue *argList, int nArgs,
2763 - DataValue *result, char **errMsg)
2764 +static int rangesetGetByNameMS(RestartData *context, DataValue *argList, int nArgs,
2765 + DataValue *result)
2767 + WindowInfo *window = MacroFocusWindow();
2768 + char **errMsg = &context->errMsg;
2769 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
2770 Rangeset *rangeset;
2771 int label;
2772 @@ -5719,9 +5917,11 @@ static int rangesetGetByNameMS(WindowInf
2773 ** if any to specify range to add - must not be rectangular). Returns the
2774 ** index of the newly added range (cases b and c), or 0 (case a).
2776 -static int rangesetAddMS(WindowInfo *window, DataValue *argList, int nArgs,
2777 - DataValue *result, char **errMsg)
2778 +static int rangesetAddMS(RestartData *context, DataValue *argList, int nArgs,
2779 + DataValue *result)
2781 + WindowInfo *window = MacroFocusWindow();
2782 + char **errMsg = &context->errMsg;
2783 textBuffer *buffer = window->buffer;
2784 RangesetTable *rangesetTable = buffer->rangesetTable;
2785 Rangeset *targetRangeset, *sourceRangeset;
2786 @@ -5818,9 +6018,11 @@ static int rangesetAddMS(WindowInfo *win
2787 ** to RangesetSubtract()/RangesetSubtractBetween(), the handling of an
2788 ** undefined destination range, and that it returns no value.
2790 -static int rangesetSubtractMS(WindowInfo *window, DataValue *argList, int nArgs,
2791 - DataValue *result, char **errMsg)
2792 +static int rangesetSubtractMS(RestartData *context, DataValue *argList, int nArgs,
2793 + DataValue *result)
2795 + WindowInfo *window = MacroFocusWindow();
2796 + char **errMsg = &context->errMsg;
2797 textBuffer *buffer = window->buffer;
2798 RangesetTable *rangesetTable = buffer->rangesetTable;
2799 Rangeset *targetRangeset, *sourceRangeset;
2800 @@ -5897,9 +6099,11 @@ static int rangesetSubtractMS(WindowInfo
2801 ** label (one alphabetic character). Returns nothing. Fails if range set
2802 ** undefined.
2804 -static int rangesetInvertMS(WindowInfo *window, DataValue *argList, int nArgs,
2805 - DataValue *result, char **errMsg)
2806 +static int rangesetInvertMS(RestartData *context, DataValue *argList, int nArgs,
2807 + DataValue *result)
2809 + WindowInfo *window = MacroFocusWindow();
2810 + char **errMsg = &context->errMsg;
2812 RangesetTable *rangesetTable = window->buffer->rangesetTable;
2813 Rangeset *rangeset;
2814 @@ -5937,9 +6141,11 @@ static int rangesetInvertMS(WindowInfo *
2815 ** argument of a rangeset label. Returns an array with the following keys:
2816 ** defined, count, color, mode.
2818 -static int rangesetInfoMS(WindowInfo *window, DataValue *argList, int nArgs,
2819 - DataValue *result, char **errMsg)
2820 +static int rangesetInfoMS(RestartData *context, DataValue *argList, int nArgs,
2821 + DataValue *result)
2823 + WindowInfo *window = MacroFocusWindow();
2824 + char **errMsg = &context->errMsg;
2825 RangesetTable *rangesetTable = window->buffer->rangesetTable;
2826 Rangeset *rangeset = NULL;
2827 int count, defined, uline;
2828 @@ -6012,9 +6218,11 @@ static int rangesetInfoMS(WindowInfo *wi
2829 ** ranges, otherwise select the individual range specified. Returns
2830 ** an array with the keys "start" and "end" and values
2832 -static int rangesetRangeMS(WindowInfo *window, DataValue *argList, int nArgs,
2833 - DataValue *result, char **errMsg)
2834 +static int rangesetRangeMS(RestartData *context, DataValue *argList, int nArgs,
2835 + DataValue *result)
2837 + WindowInfo *window = MacroFocusWindow();
2838 + char **errMsg = &context->errMsg;
2839 textBuffer *buffer = window->buffer;
2840 RangesetTable *rangesetTable = buffer->rangesetTable;
2841 Rangeset *rangeset;
2842 @@ -6078,9 +6286,11 @@ static int rangesetRangeMS(WindowInfo *w
2843 ** false (zero) if not in a range, range index (1-based) if in a range;
2844 ** fails if parameters were bad.
2846 -static int rangesetIncludesPosMS(WindowInfo *window, DataValue *argList,
2847 - int nArgs, DataValue *result, char **errMsg)
2848 +static int rangesetIncludesPosMS(RestartData *context, DataValue *argList,
2849 + int nArgs, DataValue *result)
2851 + WindowInfo *window = MacroFocusWindow();
2852 + char **errMsg = &context->errMsg;
2853 textBuffer *buffer = window->buffer;
2854 RangesetTable *rangesetTable = buffer->rangesetTable;
2855 Rangeset *rangeset;
2856 @@ -6132,9 +6342,11 @@ static int rangesetIncludesPosMS(WindowI
2857 ** found/applied. If no color is applied, any current color is removed. Returns
2858 ** true if the rangeset is valid.
2860 -static int rangesetSetColorMS(WindowInfo *window, DataValue *argList,
2861 - int nArgs, DataValue *result, char **errMsg)
2862 +static int rangesetSetColorMS(RestartData *context, DataValue *argList,
2863 + int nArgs, DataValue *result)
2865 + WindowInfo *window = MacroFocusWindow();
2866 + char **errMsg = &context->errMsg;
2867 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
2868 textBuffer *buffer = window->buffer;
2869 RangesetTable *rangesetTable = buffer->rangesetTable;
2870 @@ -6180,9 +6392,11 @@ static int rangesetSetColorMS(WindowInfo
2871 ** the underlineMode string, which should be specified as "leave" (let any
2872 ** syntax highlighting underlines to appear as undisturbed), "add" or "remove".
2874 -static int rangesetSetUnderlineMS(WindowInfo *window, DataValue *argList,
2875 - int nArgs, DataValue *result, char **errMsg)
2876 +static int rangesetSetUnderlineMS(RestartData *context, DataValue *argList,
2877 + int nArgs, DataValue *result)
2879 + WindowInfo *window = MacroFocusWindow();
2880 + char **errMsg = &context->errMsg;
2881 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
2882 textBuffer *buffer = window->buffer;
2883 RangesetTable *rangesetTable = buffer->rangesetTable;
2884 @@ -6232,9 +6446,11 @@ static int rangesetSetUnderlineMS(Window
2885 ** Set the name of a range set's ranges. Returns
2886 ** true if the rangeset is valid.
2888 -static int rangesetSetNameMS(WindowInfo *window, DataValue *argList,
2889 - int nArgs, DataValue *result, char **errMsg)
2890 +static int rangesetSetNameMS(RestartData *context, DataValue *argList,
2891 + int nArgs, DataValue *result)
2893 + WindowInfo *window = MacroFocusWindow();
2894 + char **errMsg = &context->errMsg;
2895 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
2896 textBuffer *buffer = window->buffer;
2897 RangesetTable *rangesetTable = buffer->rangesetTable;
2898 @@ -6278,9 +6494,11 @@ static int rangesetSetNameMS(WindowInfo
2899 ** Change a range's modification response. Returns true if the rangeset is
2900 ** valid and the response type name is valid.
2902 -static int rangesetSetModeMS(WindowInfo *window, DataValue *argList,
2903 - int nArgs, DataValue *result, char **errMsg)
2904 +static int rangesetSetModeMS(RestartData *context, DataValue *argList,
2905 + int nArgs, DataValue *result)
2907 + WindowInfo *window = MacroFocusWindow();
2908 + char **errMsg = &context->errMsg;
2909 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
2910 textBuffer *buffer = window->buffer;
2911 RangesetTable *rangesetTable = buffer->rangesetTable;
2912 @@ -6462,9 +6680,11 @@ static int fillStyleResult(DataValue *re
2913 ** ["italic"] '1' if style is italic, '0' otherwise
2916 -static int getStyleByNameMS(WindowInfo *window, DataValue *argList, int nArgs,
2917 - DataValue *result, char **errMsg)
2918 +static int getStyleByNameMS(RestartData *context, DataValue *argList, int nArgs,
2919 + DataValue *result)
2921 + WindowInfo *window = MacroFocusWindow();
2922 + char **errMsg = &context->errMsg;
2923 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
2924 char *styleName;
2926 @@ -6502,9 +6722,11 @@ static int getStyleByNameMS(WindowInfo *
2927 ** ["extent"] Forward distance from position over which style applies
2930 -static int getStyleAtPosMS(WindowInfo *window, DataValue *argList, int nArgs,
2931 - DataValue *result, char **errMsg)
2932 +static int getStyleAtPosMS(RestartData *context, DataValue *argList, int nArgs,
2933 + DataValue *result)
2935 + WindowInfo *window = MacroFocusWindow();
2936 + char **errMsg = &context->errMsg;
2937 int patCode;
2938 int bufferPos;
2939 textBuffer *buf = window->buffer;
2940 @@ -6607,9 +6829,11 @@ static int fillPatternResult(DataValue *
2941 ** The returned array looks like this:
2942 ** ["style"] Name of style
2944 -static int getPatternByNameMS(WindowInfo *window, DataValue *argList, int nArgs,
2945 - DataValue *result, char **errMsg)
2946 +static int getPatternByNameMS(RestartData *context, DataValue *argList, int nArgs,
2947 + DataValue *result)
2949 + WindowInfo *window = MacroFocusWindow();
2950 + char **errMsg = &context->errMsg;
2951 char stringStorage[1][TYPE_INT_STR_SIZE(int)];
2952 char *patternName = NULL;
2953 highlightPattern *pattern;
2954 @@ -6645,9 +6869,11 @@ static int getPatternByNameMS(WindowInfo
2955 ** ["style"] Name of style
2956 ** ["extent"] Distance from position over which this pattern applies
2958 -static int getPatternAtPosMS(WindowInfo *window, DataValue *argList, int nArgs,
2959 - DataValue *result, char **errMsg)
2960 +static int getPatternAtPosMS(RestartData *context, DataValue *argList, int nArgs,
2961 + DataValue *result)
2963 + WindowInfo *window = MacroFocusWindow();
2964 + char **errMsg = &context->errMsg;
2965 int bufferPos = -1;
2966 textBuffer *buffer = window->buffer;
2967 int patCode = 0;
2968 @@ -6703,9 +6929,11 @@ static int getPatternAtPosMS(WindowInfo
2969 ** of "pos" holds "-1", "len" holds "0" and "direction" holds "-1".
2972 -static int getMatchingMS(WindowInfo *window, DataValue *argList, int nArgs,
2973 - DataValue *result, char **errMsg)
2974 +static int getMatchingMS(RestartData *context, DataValue *argList, int nArgs,
2975 + DataValue *result)
2977 + WindowInfo *window = MacroFocusWindow();
2978 + char **errMsg = &context->errMsg;
2979 int startPos;
2980 int matchPos, matchLen;
2981 int direction;
2982 @@ -6780,9 +7008,11 @@ static int getMatchingMS(WindowInfo *win
2983 /* Insert a string into the acutal dictionary */
2984 /* Syntax : dictinsert(string) % assuming weight = 1 */
2985 /* dictinsert(string, weight) */
2986 -static int dictinsertMS(WindowInfo *window, DataValue *argList, int nArgs,
2987 - DataValue *result, char **errMsg)
2988 +static int dictinsertMS(RestartData *context, DataValue *argList, int nArgs,
2989 + DataValue *result)
2991 + WindowInfo *window = MacroFocusWindow();
2992 + char **errMsg = &context->errMsg;
2993 static long nr_insertions = 0;
2994 int weight = 1;
2996 @@ -6830,9 +7060,11 @@ static int dictinsertMS(WindowInfo *wind
2997 /* Test if string is an element of the acutal dictionary */
2998 /* Syntax : weight = dictiselement(string) */
2999 /* Output argument : (integer) weight of element */
3000 -static int dictiselementMS(WindowInfo *window, DataValue *argList, int nArgs,
3001 - DataValue *result, char **errMsg)
3002 +static int dictiselementMS(RestartData *context, DataValue *argList, int nArgs,
3003 + DataValue *result)
3005 + WindowInfo *window = MacroFocusWindow();
3006 + char **errMsg = &context->errMsg;
3007 char stringStorage[25], *string;
3008 unsigned long weight;
3010 @@ -6862,9 +7094,11 @@ static int dictiselementMS(WindowInfo *w
3012 /* Load/append file to current dictionary */
3013 /* Syntax : dict_append(filename) */
3014 -static int dictappendMS(WindowInfo *window, DataValue *argList, int nArgs,
3015 - DataValue *result, char **errMsg)
3016 +static int dictappendMS(RestartData *context, DataValue *argList, int nArgs,
3017 + DataValue *result)
3019 + WindowInfo *window = MacroFocusWindow();
3020 + char **errMsg = &context->errMsg;
3021 char stringStorage[25], *string;
3023 /* Validate arguments and convert to int */
3024 @@ -6887,9 +7121,11 @@ static int dictappendMS(WindowInfo *wind
3025 /* dict_save(filename) => set dictionary filename (otherwise default filename is used) */
3026 /* dict_save("") => return current filename as string */
3027 /* dict_save(autoSave, cumulSave) => autoSave = "on"/"off"/"flush", cumulSave=0,1,2,3,... */
3028 -static int dictsaveMS(WindowInfo *window, DataValue *argList, int nArgs,
3029 - DataValue *result, char **errMsg)
3030 +static int dictsaveMS(RestartData *context, DataValue *argList, int nArgs,
3031 + DataValue *result)
3033 + WindowInfo *window = MacroFocusWindow();
3034 + char **errMsg = &context->errMsg;
3035 int cumulSave = 0;
3037 char stringStorage[25], *string;
3038 @@ -6957,9 +7193,11 @@ static int dictsaveMS(WindowInfo *window
3040 #define MAXMATCHES 128
3042 -static int dictcompleteMS(WindowInfo *window, DataValue *argList, int nArgs,
3043 - DataValue *result, char **errMsg)
3044 +static int dictcompleteMS(RestartData *context, DataValue *argList, int nArgs,
3045 + DataValue *result)
3047 + WindowInfo *window = MacroFocusWindow();
3048 + char **errMsg = &context->errMsg;
3049 int minchars = 0;
3050 int maxmatches = 1;
3051 static char *s2[MAXMATCHES]; /* at max, 128 possible completions can be returned */
3052 @@ -7028,9 +7266,11 @@ static int dictcompleteMS(WindowInfo *wi
3053 ** UL convertPos patch:
3054 ** translate given line / column parameter to text buffer position.
3056 -static int toPosMS(WindowInfo *window, DataValue *argList, int nArgs,
3057 - DataValue *result, char **errMsg)
3058 +static int toPosMS(RestartData *context, DataValue *argList, int nArgs,
3059 + DataValue *result)
3061 + WindowInfo *window = MacroFocusWindow();
3062 + char **errMsg = &context->errMsg;
3063 char *lineStr, stringStorage1[TYPE_INT_STR_SIZE(int)];
3064 char *colStr , stringStorage2[TYPE_INT_STR_SIZE(int)];
3065 char *lineColString;
3066 @@ -7129,9 +7369,11 @@ static int toPosMS(WindowInfo *window, D
3067 ** UL convertPos patch:
3068 ** translate given text buffer position to line number.
3070 -static int toLineMS(WindowInfo *window, DataValue *argList, int nArgs,
3071 - DataValue *result, char **errMsg)
3072 +static int toLineMS(RestartData *context, DataValue *argList, int nArgs,
3073 + DataValue *result)
3075 + WindowInfo *window = MacroFocusWindow();
3076 + char **errMsg = &context->errMsg;
3077 int line, column;
3078 int pos;
3080 @@ -7174,9 +7416,11 @@ static int toLineMS(WindowInfo *window,
3081 ** UL convertPos patch:
3082 ** translate given text buffer position to column number.
3084 -static int toColumnMS(WindowInfo *window, DataValue *argList, int nArgs,
3085 - DataValue *result, char **errMsg)
3086 +static int toColumnMS(RestartData *context, DataValue *argList, int nArgs,
3087 + DataValue *result)
3089 + WindowInfo *window = MacroFocusWindow();
3090 + char **errMsg = &context->errMsg;
3091 int line, column;
3092 int pos;
3093 textBuffer *buf = window->buffer;
3094 diff --quilt old/source/macro.h new/source/macro.h
3095 --- old/source/macro.h
3096 +++ new/source/macro.h
3097 @@ -37,7 +37,7 @@
3099 typedef struct BuiltInSubrNameTag {
3100 const char *name; /* its macro identifier */
3101 - BuiltInSubr macroSubr; /* pointer to the function to call */
3102 + BuiltInSubr *macroSubr; /* pointer to the function to call */
3103 } BuiltInSubrName;
3105 /* Structure used to build an initialized static array, each entry describing a