From cb506ea412d51f8b6290901834902633681e4529 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Thu, 29 Dec 2005 13:27:12 +0000 Subject: [PATCH] Factor smjs_do_file out of smjs_load_hooks. --- src/scripting/smjs/core.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/scripting/smjs/core.c b/src/scripting/smjs/core.c index 3864c7dd8..14d90f4a2 100644 --- a/src/scripting/smjs/core.c +++ b/src/scripting/smjs/core.c @@ -69,32 +69,39 @@ reported: static JSRuntime *smjs_rt; static void -smjs_load_hooks(void) +smjs_do_file(unsigned char *path) { jsval rval; struct string script; - unsigned char *path; - - assert(smjs_ctx); if (!init_string(&script)) return; - if (elinks_home) { - path = straconcat(elinks_home, SMJS_HOOKS_FILENAME, NULL); - } else { - path = stracpy(CONFDIR "/" SMJS_HOOKS_FILENAME); - } - if (add_file_to_string(&script, path) && JS_FALSE == JS_EvaluateScript(smjs_ctx, JS_GetGlobalObject(smjs_ctx), script.source, script.length, path, 1, &rval)) alert_smjs_error("error loading default script file"); - mem_free(path); done_string(&script); } +static void +smjs_load_hooks(void) +{ + unsigned char *path; + + assert(smjs_ctx); + + if (elinks_home) { + path = straconcat(elinks_home, SMJS_HOOKS_FILENAME, NULL); + } else { + path = stracpy(CONFDIR "/" SMJS_HOOKS_FILENAME); + } + + smjs_do_file(path); + mem_free(path); +} + void init_smjs(struct module *module) {