From 7b092af628f545c13fb7dd61c7693b0f845dce13 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sun, 12 Feb 2006 04:25:10 +0000 Subject: [PATCH 1/2] SEE: document.writeln: always add new line Add the new-line character even if SEE_value_to_unsigned_char returns NULL. --- src/ecmascript/see/document.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ecmascript/see/document.c b/src/ecmascript/see/document.c index 51ee5b50a..8705849b7 100644 --- a/src/ecmascript/see/document.c +++ b/src/ecmascript/see/document.c @@ -217,9 +217,10 @@ js_document_write_do(struct SEE_interpreter *interp, struct SEE_object *self, if (code) { add_to_string(ret, code); mem_free(code); - if (newline) - add_char_to_string(ret, '\n'); } + + if (newline) + add_char_to_string(ret, '\n'); } #ifdef CONFIG_LEDS /* XXX: I don't know about you, but I have *ENOUGH* of those 'Undefined From a464157d4d81a5a37e9d7c295b183f048abeb3fd Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sun, 12 Feb 2006 04:33:42 +0000 Subject: [PATCH 2/2] SEE & SMJS: document.write(ln): use all arguments Additionally add a test to test/ecmascript/document_write.html. Thanks to Kirk Reiser for observing that ELinks only printed the first. --- src/ecmascript/see/document.c | 14 ++++++++++---- src/ecmascript/spidermonkey/document.c | 9 +++++++-- test/ecmascript/document_write.html | 3 ++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/ecmascript/see/document.c b/src/ecmascript/see/document.c index 8705849b7..49bc455e4 100644 --- a/src/ecmascript/see/document.c +++ b/src/ecmascript/see/document.c @@ -212,11 +212,17 @@ js_document_write_do(struct SEE_interpreter *interp, struct SEE_object *self, struct string *ret = g->ret; if (argc >= 1 && ret) { - unsigned char *code = SEE_value_to_unsigned_char(interp, argv[0]); + int i = 0; - if (code) { - add_to_string(ret, code); - mem_free(code); + for (; i < argc; ++i) { + unsigned char *code; + + code = SEE_value_to_unsigned_char(interp, argv[i]); + + if (code) { + add_to_string(ret, code); + mem_free(code); + } } if (newline) diff --git a/src/ecmascript/spidermonkey/document.c b/src/ecmascript/spidermonkey/document.c index 896daacf7..cef2aa236 100644 --- a/src/ecmascript/spidermonkey/document.c +++ b/src/ecmascript/spidermonkey/document.c @@ -212,9 +212,14 @@ document_write_do(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, struct string *ret = interpreter->ret; if (argc >= 1 && ret) { - unsigned char *code = jsval_to_string(ctx, &argv[0]); + int i = 0; + + for (; i < argc; ++i) { + unsigned char *code = jsval_to_string(ctx, &argv[i]); + + add_to_string(ret, code); + } - add_to_string(ret, code); if (newline) add_char_to_string(ret, '\n'); } diff --git a/test/ecmascript/document_write.html b/test/ecmascript/document_write.html index 2721529ae..02856d605 100644 --- a/test/ecmascript/document_write.html +++ b/test/ecmascript/document_write.html @@ -3,7 +3,8 @@ history.html
onload.html