- Revision
- 259564
- Author
- [email protected]
- Date
- 2020-04-05 21:34:36 -0700 (Sun, 05 Apr 2020)
Log Message
JSC shell shouldn't treat NUL as a terminator when printing a JS string
https://bugs.webkit.org/show_bug.cgi?id=210037
Reviewed by Darin Adler.
JSTests:
* .gitattributes:
* ChakraCore.yaml:
* ChakraCore/test/es5/hasItem.baseline-jsc: Added.
Update baseline and mark it diffable (as plaintext) in spite of containing \0.
Source/_javascript_Core:
Since JS strings aren't null-terminated, it's probably a better experience to not stop printing when we see \0.
That is, 'abc\0def' should be printed as `abcdef` and not `abc`.
This patch updates our printing of evaluation results as well as the print / printErr / debug functions.
* jsc.cpp:
(printInternal):
(functionDebug):
(runInteractive):
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/.gitattributes (259563 => 259564)
--- trunk/JSTests/.gitattributes 2020-04-06 04:22:04 UTC (rev 259563)
+++ trunk/JSTests/.gitattributes 2020-04-06 04:34:36 UTC (rev 259564)
@@ -1,3 +1,5 @@
+ChakraCore/test/es5/hasItem.baseline-jsc diff
+
test262/test/language/expressions/logical-assignment/lgcl-and-whitespace.js svn-properties=allow-tabs=on
test262/test/language/expressions/logical-assignment/lgcl-or-whitespace.js svn-properties=allow-tabs=on
test262/test/language/expressions/logical-assignment/lgcl-nullish-whitespace.js svn-properties=allow-tabs=on
Added: trunk/JSTests/ChakraCore/test/es5/hasItem.baseline-jsc (0 => 259564)
--- trunk/JSTests/ChakraCore/test/es5/hasItem.baseline-jsc (rev 0)
+++ trunk/JSTests/ChakraCore/test/es5/hasItem.baseline-jsc 2020-04-06 04:34:36 UTC (rev 259564)
@@ -0,0 +1,110 @@
+Test empty object
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test empty array
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test number object
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test string object
+ pass (abc)
+ pass (-1)
+ pass ...can not defineProperty... (0)
+ pass ...can not defineProperty... (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test Object
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test global object
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test object with 1 property
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test object with many properties
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test object with accessor
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test array
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
+Test es5 array
+ pass (abc)
+ pass (-1)
+ pass (0)
+ pass (1)
+ pass (10)
+ pass (4294967294)
+ pass (x y)
+ pass (x��y)
+ pass (x����y)
Modified: trunk/JSTests/ChakraCore.yaml (259563 => 259564)
--- trunk/JSTests/ChakraCore.yaml 2020-04-06 04:22:04 UTC (rev 259563)
+++ trunk/JSTests/ChakraCore.yaml 2020-04-06 04:34:36 UTC (rev 259564)
@@ -1469,7 +1469,7 @@
- path: ChakraCore/test/es5/enumerable.js
cmd: runChakra :baseline, "NoException", "enumerable.baseline-jsc", []
- path: ChakraCore/test/es5/hasItem.js
- cmd: runChakra :baseline, "NoException", "hasItem.baseline", []
+ cmd: runChakra :baseline, "NoException", "hasItem.baseline-jsc", []
- path: ChakraCore/test/es5/regexSpace.js
cmd: runChakra :baseline, "NoException", "regexSpace.baseline", []
- path: ChakraCore/test/es5/EnumeratingWithES5.js
Modified: trunk/JSTests/ChangeLog (259563 => 259564)
--- trunk/JSTests/ChangeLog 2020-04-06 04:22:04 UTC (rev 259563)
+++ trunk/JSTests/ChangeLog 2020-04-06 04:34:36 UTC (rev 259564)
@@ -1,3 +1,15 @@
+2020-04-05 Ross Kirsling <[email protected]>
+
+ JSC shell shouldn't treat NUL as a terminator when printing a JS string
+ https://bugs.webkit.org/show_bug.cgi?id=210037
+
+ Reviewed by Darin Adler.
+
+ * .gitattributes:
+ * ChakraCore.yaml:
+ * ChakraCore/test/es5/hasItem.baseline-jsc: Added.
+ Update baseline and mark it diffable (as plaintext) in spite of containing \0.
+
2020-04-05 Alexey Shvayka <[email protected]>
Octal escapes should be max 3 digits and syntax errors in Unicode patterns
Modified: trunk/Source/_javascript_Core/ChangeLog (259563 => 259564)
--- trunk/Source/_javascript_Core/ChangeLog 2020-04-06 04:22:04 UTC (rev 259563)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-04-06 04:34:36 UTC (rev 259564)
@@ -1,3 +1,20 @@
+2020-04-05 Ross Kirsling <[email protected]>
+
+ JSC shell shouldn't treat NUL as a terminator when printing a JS string
+ https://bugs.webkit.org/show_bug.cgi?id=210037
+
+ Reviewed by Darin Adler.
+
+ Since JS strings aren't null-terminated, it's probably a better experience to not stop printing when we see \0.
+ That is, 'abc\0def' should be printed as `abcdef` and not `abc`.
+
+ This patch updates our printing of evaluation results as well as the print / printErr / debug functions.
+
+ * jsc.cpp:
+ (printInternal):
+ (functionDebug):
+ (runInteractive):
+
2020-04-05 Yusuke Suzuki <[email protected]>
Putting "memory" back to ensureStillAliveHere
Modified: trunk/Source/_javascript_Core/jsc.cpp (259563 => 259564)
--- trunk/Source/_javascript_Core/jsc.cpp 2020-04-06 04:22:04 UTC (rev 259563)
+++ trunk/Source/_javascript_Core/jsc.cpp 2020-04-06 04:34:36 UTC (rev 259564)
@@ -1268,7 +1268,8 @@
RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto string = cStringFromViewWithString(globalObject, scope, viewWithString);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
- if (fprintf(out, "%s", string.data()) < 0)
+ fwrite(string.data(), sizeof(char), string.length(), out);
+ if (ferror(out))
goto fail;
}
@@ -1289,7 +1290,9 @@
RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto string = cStringFromViewWithString(globalObject, scope, viewWithString);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
- fprintf(stderr, "--> %s\n", string.data());
+ fputs("--> ", stderr);
+ fwrite(string.data(), sizeof(char), string.length(), stderr);
+ fputc('\n', stderr);
return JSValue::encode(jsUndefined());
}
@@ -2795,10 +2798,14 @@
NakedPtr<Exception> evaluationException;
JSValue returnValue = evaluate(globalObject, jscSource(line, sourceOrigin, sourceOrigin.string()), JSValue(), evaluationException);
#endif
- if (evaluationException)
- printf("Exception: %s\n", evaluationException->value().toWTFString(globalObject).utf8().data());
- else
- printf("%s\n", returnValue.toWTFString(globalObject).utf8().data());
+ CString result;
+ if (evaluationException) {
+ fputs("Exception: ", stdout);
+ result = evaluationException->value().toWTFString(globalObject).utf8();
+ } else
+ result = returnValue.toWTFString(globalObject).utf8();
+ fwrite(result.data(), sizeof(char), result.length(), stdout);
+ putchar('\n');
scope.clearException();
vm.drainMicrotasks();