⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259564 in webkit


Ignore:
Timestamp:
Apr 5, 2020, 9:34:36 PM (6 years ago)
Author:
Ross Kirsling
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/JavaScriptCore:

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):

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/.gitattributes

    r259529 r259564  
     1ChakraCore/test/es5/hasItem.baseline-jsc diff
     2
    13test262/test/language/expressions/logical-assignment/lgcl-and-whitespace.js svn-properties=allow-tabs=on
    24test262/test/language/expressions/logical-assignment/lgcl-or-whitespace.js svn-properties=allow-tabs=on
  • trunk/JSTests/ChakraCore.yaml

    r252758 r259564  
    14701470  cmd: runChakra :baseline, "NoException", "enumerable.baseline-jsc", []
    14711471- path: ChakraCore/test/es5/hasItem.js
    1472   cmd: runChakra :baseline, "NoException", "hasItem.baseline", []
     1472  cmd: runChakra :baseline, "NoException", "hasItem.baseline-jsc", []
    14731473- path: ChakraCore/test/es5/regexSpace.js
    14741474  cmd: runChakra :baseline, "NoException", "regexSpace.baseline", []
  • trunk/JSTests/ChangeLog

    r259546 r259564  
     12020-04-05  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        JSC shell shouldn't treat NUL as a terminator when printing a JS string
     4        https://bugs.webkit.org/show_bug.cgi?id=210037
     5
     6        Reviewed by Darin Adler.
     7
     8        * .gitattributes:
     9        * ChakraCore.yaml:
     10        * ChakraCore/test/es5/hasItem.baseline-jsc: Added.
     11        Update baseline and mark it diffable (as plaintext) in spite of containing \0.
     12
    1132020-04-05  Alexey Shvayka  <shvaikalesh@gmail.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r259558 r259564  
     12020-04-05  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        JSC shell shouldn't treat NUL as a terminator when printing a JS string
     4        https://bugs.webkit.org/show_bug.cgi?id=210037
     5
     6        Reviewed by Darin Adler.
     7
     8        Since JS strings aren't null-terminated, it's probably a better experience to not stop printing when we see \0.
     9        That is, 'abc\0def' should be printed as `abcdef` and not `abc`.
     10
     11        This patch updates our printing of evaluation results as well as the print / printErr / debug functions.
     12
     13        * jsc.cpp:
     14        (printInternal):
     15        (functionDebug):
     16        (runInteractive):
     17
    1182020-04-05  Yusuke Suzuki  <ysuzuki@apple.com>
    219
  • trunk/Source/JavaScriptCore/jsc.cpp

    r258059 r259564  
    12691269        auto string = cStringFromViewWithString(globalObject, scope, viewWithString);
    12701270        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    1271         if (fprintf(out, "%s", string.data()) < 0)
     1271        fwrite(string.data(), sizeof(char), string.length(), out);
     1272        if (ferror(out))
    12721273            goto fail;
    12731274    }
     
    12901291    auto string = cStringFromViewWithString(globalObject, scope, viewWithString);
    12911292    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    1292     fprintf(stderr, "--> %s\n", string.data());
     1293    fputs("--> ", stderr);
     1294    fwrite(string.data(), sizeof(char), string.length(), stderr);
     1295    fputc('\n', stderr);
    12931296    return JSValue::encode(jsUndefined());
    12941297}
     
    27962799        JSValue returnValue = evaluate(globalObject, jscSource(line, sourceOrigin, sourceOrigin.string()), JSValue(), evaluationException);
    27972800#endif
    2798         if (evaluationException)
    2799             printf("Exception: %s\n", evaluationException->value().toWTFString(globalObject).utf8().data());
    2800         else
    2801             printf("%s\n", returnValue.toWTFString(globalObject).utf8().data());
     2801        CString result;
     2802        if (evaluationException) {
     2803            fputs("Exception: ", stdout);
     2804            result = evaluationException->value().toWTFString(globalObject).utf8();
     2805        } else
     2806            result = returnValue.toWTFString(globalObject).utf8();
     2807        fwrite(result.data(), sizeof(char), result.length(), stdout);
     2808        putchar('\n');
    28022809
    28032810        scope.clearException();
Note: See TracChangeset for help on using the changeset viewer.