Skip to content

Commit bb0fa48

Browse files
committed
dsl: make clearing app data in opt_vm_clear() optional
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 0ae4783 commit bb0fa48

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

dsl/optscript.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,13 @@ opt_vm_new (MIO *in, MIO *out, MIO *err)
647647
}
648648

649649
void
650-
opt_vm_clear (OptVM *vm)
650+
opt_vm_clear (OptVM *vm, bool clear_app_data)
651651
{
652652
ptrArrayClear (vm->estack);
653653
ptrArrayClear (vm->ostack);
654654
vm_dstack_clear (vm);
655-
vm->app_data = NULL;
655+
if (clear_app_data)
656+
vm->app_data = NULL;
656657
dict_op_clear (vm->error);
657658
}
658659

dsl/optscript.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void opt_vm_print_prompt (OptVM *vm);
4141
int opt_vm_help (OptVM *vm, MIO *out,
4242
struct OptHelpExtender *extop, void *data);
4343

44-
void opt_vm_clear (OptVM *vm);
44+
void opt_vm_clear (OptVM *vm, bool clear_app_data);
4545
void opt_vm_dstack_push (OptVM *vm, EsObject *dict);
4646
void opt_vm_dstack_pop (OptVM *vm);
4747

extra-cmds/optscript-repl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ main(int argc, char **argv)
211211
r = optscript_run (vm, file? NULL: "OPT", &renew);
212212
if (renew)
213213
{
214-
opt_vm_clear (vm);
214+
opt_vm_clear (vm, true);
215215
opt_vm_dstack_push (vm, dict);
216216
renew = false;
217217
goto renew;

main/lregex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ extern void notifyRegexInputEnd (struct lregexControlBlock *lcb)
21472147
{
21482148
scriptEvalHook (optvm, lcb, SCRIPT_HOOK_SEQUEL);
21492149
opt_vm_set_app_data (optvm, NULL);
2150-
opt_vm_clear (optvm);
2150+
opt_vm_clear (optvm, true);
21512151
opt_dict_clear (lcb->local_dict);
21522152
unsigned long endline = getInputLineNumber ();
21532153
fillEndLineFieldOfUpperScopes (lcb, endline);

0 commit comments

Comments
 (0)