Skip to content
Snippets Groups Projects
Commit 26348dd4 authored by deuce's avatar deuce
Browse files

Support terminating the script from the debugger before it actually runs.

parent 8f5b9e0a
Branches
Tags
No related merge requests found
...@@ -935,6 +935,7 @@ long js_exec(const char *fname, char** args) ...@@ -935,6 +935,7 @@ long js_exec(const char *fname, char** args)
long double start; long double start;
long double diff; long double diff;
JSBool exec_result; JSBool exec_result;
BOOL abort = FALSE;
if(fname!=NULL) { if(fname!=NULL) {
if(isfullpath(fname)) { if(isfullpath(fname)) {
...@@ -1041,21 +1042,25 @@ long js_exec(const char *fname, char** args) ...@@ -1041,21 +1042,25 @@ long js_exec(const char *fname, char** args)
js_PrepareToExecute(js_cx, js_glob, fname==NULL ? NULL : path, orig_cwd, js_glob); js_PrepareToExecute(js_cx, js_glob, fname==NULL ? NULL : path, orig_cwd, js_glob);
start=xp_timer(); start=xp_timer();
if(debugger) if(debugger)
debug_prompt(js_cx, js_script); abort = debug_prompt(js_cx, js_script) == DEBUG_EXIT;
exec_result = JS_ExecuteScript(js_cx, js_glob, js_script, &rval); if (abort) {
JS_GetProperty(js_cx, js_glob, "exit_code", &rval);
if(rval!=JSVAL_VOID && JSVAL_IS_NUMBER(rval)) {
char *p;
JSVALUE_TO_MSTRING(js_cx, rval, p, NULL);
mfprintf(statfp,"Using JavaScript exit_code: %s",p);
free(p);
JS_ValueToInt32(js_cx,rval,&result);
} else if(!exec_result)
result = EXIT_FAILURE; result = EXIT_FAILURE;
js_EvalOnExit(js_cx, js_glob, &cb); } else {
exec_result = JS_ExecuteScript(js_cx, js_glob, js_script, &rval);
JS_ReportPendingException(js_cx); JS_GetProperty(js_cx, js_glob, "exit_code", &rval);
if(rval!=JSVAL_VOID && JSVAL_IS_NUMBER(rval)) {
char *p;
JSVALUE_TO_MSTRING(js_cx, rval, p, NULL);
mfprintf(statfp,"Using JavaScript exit_code: %s",p);
free(p);
JS_ValueToInt32(js_cx,rval,&result);
} else if(!exec_result)
result = EXIT_FAILURE;
js_EvalOnExit(js_cx, js_glob, &cb);
JS_ReportPendingException(js_cx);
}
if((diff=xp_timer()-start) > 0) if((diff=xp_timer()-start) > 0)
mfprintf(statfp,"%s executed in %.2Lf seconds" mfprintf(statfp,"%s executed in %.2Lf seconds"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment