summaryrefslogtreecommitdiff
path: root/quickjs-libc.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-05 18:22:34 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-05 18:22:34 +0200
commit00b709dfff9d858b53edfd9cb8a185b120e0cbd8 (patch)
tree8ef477cc5449a485edadd9a91cf1a61c102112a0 /quickjs-libc.c
parent159fe289e3b26727f7d85ce062689afb668230c1 (diff)
downloadquickjs-00b709dfff9d858b53edfd9cb8a185b120e0cbd8.tar.gz
quickjs-00b709dfff9d858b53edfd9cb8a185b120e0cbd8.zip
flush stdout in console.log() (#309)
Diffstat (limited to 'quickjs-libc.c')
-rw-r--r--quickjs-libc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/quickjs-libc.c b/quickjs-libc.c
index fd5d412..a659084 100644
--- a/quickjs-libc.c
+++ b/quickjs-libc.c
@@ -3825,6 +3825,15 @@ static JSValue js_print(JSContext *ctx, JSValueConst this_val,
return JS_UNDEFINED;
}
+static JSValue js_console_log(JSContext *ctx, JSValueConst this_val,
+ int argc, JSValueConst *argv)
+{
+ JSValue ret;
+ ret = js_print(ctx, this_val, argc, argv);
+ fflush(stdout);
+ return ret;
+}
+
void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
{
JSValue global_obj, console, args;
@@ -3835,7 +3844,7 @@ void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
console = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, console, "log",
- JS_NewCFunction(ctx, js_print, "log", 1));
+ JS_NewCFunction(ctx, js_console_log, "log", 1));
JS_SetPropertyStr(ctx, global_obj, "console", console);
/* same methods as the mozilla JS shell */