aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-28 19:11:39 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-28 20:25:17 +1100
commitab70a8709c6af43311ab716d24f503e3ac2fe37e (patch)
tree028e9ce116d9bf9de799817c28050b7d64513425 /src
parentf77d479fbb1a2a2160dcc559a1870b1f0f460a4d (diff)
downloadfengari-ab70a8709c6af43311ab716d24f503e3ac2fe37e.tar.gz
fengari-ab70a8709c6af43311ab716d24f503e3ac2fe37e.tar.bz2
fengari-ab70a8709c6af43311ab716d24f503e3ac2fe37e.zip
src/lauxlib.js: lua_writestringerror gets a console.error invocation per newline
Diffstat (limited to 'src')
-rw-r--r--src/lauxlib.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index aafdfff..584f386 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -869,7 +869,14 @@ const lua_writestringerror = function() {
for (let i=0; i<arguments.length; i++) {
let a = arguments[i];
if (typeof process === "undefined") {
- console.error(a);
+ /* split along new lines for separate console.error invocations */
+ do {
+ /* regexp uses [\d\D] to work around matching new lines
+ the 's' flag is non-standard */
+ let r = /([^\n]*)\n?([\d\D]*)/.exec(a);
+ console.error(r[1]);
+ a = r[2];
+ } while (a !== "");
} else {
process.stderr.write(a);
}