]> git.kaiwu.me - quickjs.git/commitdiff
fixed HTML comments (chqrlie)
authorFabrice Bellard <fabrice@bellard.org>
Sat, 12 Apr 2025 10:38:51 +0000 (12:38 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 12 Apr 2025 10:38:51 +0000 (12:38 +0200)
TODO
quickjs.c
test262_errors.txt

diff --git a/TODO b/TODO
index 0cefa973e8180db4e6a8a61d11c3dd72f8bae428..5f874ca3ccbd367578206e4e5bef5bd5c2ee7ec6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -62,6 +62,6 @@ Optimization ideas:
 Test262o:   0/11262 errors, 463 excluded
 Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
 
-Result: 30/76964 errors, 3147 excluded, 6912 skipped
+Result: 27/76964 errors, 3147 excluded, 6912 skipped
 Test262 commit: 56e77d6325067a545ea7e8ff5be5d9284334e33c
 
index 8fb5f657fd4bdcaa8a72f454098a0e7d5504cb03..73230538f1f963055bea0d3ed99beb68d3cd3086 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -20013,6 +20013,7 @@ typedef struct JSParseState {
     JSToken token;
     BOOL got_lf; /* true if got line feed before the current token */
     const uint8_t *last_ptr;
+    const uint8_t *buf_start;
     const uint8_t *buf_ptr;
     const uint8_t *buf_end;
 
@@ -20883,8 +20884,8 @@ static __exception int next_token(JSParseState *s)
             p += 2;
             s->token.val = TOK_MINUS_ASSIGN;
         } else if (p[1] == '-') {
-            if (s->allow_html_comments &&
-                p[2] == '>' && s->last_line_num != s->line_num) {
+            if (s->allow_html_comments && p[2] == '>' &&
+                (s->got_lf || s->last_ptr == s->buf_start)) {
                 /* Annex B: `-->` at beginning of line is an html comment end.
                    It extends to the end of the line.
                  */
@@ -34235,7 +34236,7 @@ static void js_parse_init(JSContext *ctx, JSParseState *s,
     s->ctx = ctx;
     s->filename = filename;
     s->line_num = 1;
-    s->buf_ptr = (const uint8_t *)input;
+    s->buf_start = s->buf_ptr = (const uint8_t *)input;
     s->buf_end = s->buf_ptr + input_len;
     s->token.val = ' ';
     s->token.line_num = 1;
index de18e57dfbdc311201d6f7d4a0841900abae1462..f994eb3dc993d47fabaccb6167764f0eda97abb6 100644 (file)
@@ -1,6 +1,3 @@
-test262/test/annexB/language/comments/single-line-html-close-first-line-1.js:1: unexpected error type: SyntaxError: unexpected token in expression: '>'
-test262/test/annexB/language/comments/single-line-html-close-first-line-2.js:1: unexpected error type: SyntaxError: unexpected token in expression: '>'
-test262/test/annexB/language/comments/single-line-html-close-first-line-3.js:1: unexpected error type: SyntaxError: unexpected token in expression: '>'
 test262/test/language/destructuring/binding/keyed-destructuring-property-reference-target-evaluation-order-with-bindings.js:73: Test262Error: Actual [binding::source, binding::sourceKey, sourceKey, get source, binding::defaultValue, binding::varTarget] and expected [binding::source, binding::sourceKey, sourceKey, binding::varTarget, get source, binding::defaultValue] should have the same contents. 
 test262/test/language/expressions/assignment/destructuring/iterator-destructuring-property-reference-target-evaluation-order.js:42: Test262Error: Actual [source, iterator, target, target-key, target-key-tostring, iterator-step, iterator-done, set] and expected [source, iterator, target, target-key, iterator-step, iterator-done, target-key-tostring, set] should have the same contents. 
 test262/test/language/expressions/assignment/destructuring/iterator-destructuring-property-reference-target-evaluation-order.js:42: strict mode: Test262Error: Actual [source, iterator, target, target-key, target-key-tostring, iterator-step, iterator-done, set] and expected [source, iterator, target, target-key, iterator-step, iterator-done, target-key-tostring, set] should have the same contents.