mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[options] Minor optimisation. Store value of "test" option in variable
This commit is contained in:
parent
af20c0e7e8
commit
0f1e056875
@ -34,6 +34,7 @@
|
||||
#include "ecmascript/timer.h"
|
||||
#include "intl/libintl.h"
|
||||
#include "main/module.h"
|
||||
#include "main/main.h"
|
||||
#include "main/select.h"
|
||||
#include "main/timer.h"
|
||||
#include "osdep/osdep.h"
|
||||
@ -275,7 +276,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s %s %d\n", __FILE__, __FUNCTION__, text, interpreter->changed);
|
||||
#endif
|
||||
if (interpreter->changed && !get_cmd_opt_bool("test")) {
|
||||
if (interpreter->changed && !program.testjs) {
|
||||
struct document_view *doc_view = interpreter->vs->doc_view;
|
||||
struct document *document = doc_view->document;
|
||||
struct session *ses = doc_view->session;
|
||||
@ -643,7 +644,7 @@ init_ecmascript_module(struct module *module)
|
||||
if (xdg_config_home) {
|
||||
/* ecmascript console log */
|
||||
console_log_filename = straconcat(xdg_config_home, "/console.log", NULL);
|
||||
console_error_filename = get_cmd_opt_bool("test") ? stracpy("/dev/stderr") : straconcat(xdg_config_home, "/console.err", NULL);
|
||||
console_error_filename = program.testjs ? stracpy("/dev/stderr") : straconcat(xdg_config_home, "/console.err", NULL);
|
||||
/* ecmascript local storage db location */
|
||||
#ifdef CONFIG_OS_DOS
|
||||
local_storage_filename = stracpy("elinks_ls.db");
|
||||
|
@ -103,7 +103,7 @@ mjs_console_exit(js_State *J)
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
if (!get_cmd_opt_bool("test")) {
|
||||
if (!program.testjs) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ js_console_exit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *a
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
if (!get_cmd_opt_bool("test")) {
|
||||
if (!program.testjs) {
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
program.retval = JS_ToBool(ctx, argv[0]) ? RET_ERROR : RET_OK;
|
||||
|
@ -158,7 +158,7 @@ console_exit(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setUndefined();
|
||||
|
||||
if (!get_cmd_opt_bool("test")) {
|
||||
if (!program.testjs) {
|
||||
return true;
|
||||
}
|
||||
program.retval = args[0].toBoolean() ? RET_ERROR : RET_OK;
|
||||
|
@ -176,6 +176,7 @@ init(void)
|
||||
free_string_list(&url_list);
|
||||
return;
|
||||
}
|
||||
program.testjs = get_cmd_opt_bool("test");
|
||||
|
||||
if (!remote_session_flags) {
|
||||
check_stdio(&url_list);
|
||||
|
@ -20,6 +20,7 @@ struct program {
|
||||
int terminate;
|
||||
enum retval retval;
|
||||
char *path;
|
||||
unsigned int testjs:1;
|
||||
};
|
||||
|
||||
extern struct program program;
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include "elinks.h"
|
||||
|
||||
#include "config/options.h"
|
||||
#include "main/main.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/osdep.h"
|
||||
#include "osdep/signals.h"
|
||||
@ -875,7 +876,7 @@ done_draw(void)
|
||||
int
|
||||
get_output_handle(void)
|
||||
{
|
||||
if (get_cmd_opt_bool("test")) {
|
||||
if (program.testjs) {
|
||||
return open("/dev/null", O_WRONLY);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user