Welcome! Log In Create A New Profile

Advanced

[njs] Fixed parsing multiline comments.

Dmitry Volyntsev
January 29, 2019 10:16AM
details: https://hg.nginx.org/njs/rev/348a34597bab
branches:
changeset: 741:348a34597bab
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Jan 29 18:15:03 2019 +0300
description:
Fixed parsing multiline comments.

diffstat:

njs/njs_lexer.c | 6 ++----
njs/test/njs_interactive_test.c | 17 +++++++++++++++++
njs/test/njs_unit_test.c | 3 +++
3 files changed, 22 insertions(+), 4 deletions(-)

diffs (56 lines):

diff -r ef39ae753b9e -r 348a34597bab njs/njs_lexer.c
--- a/njs/njs_lexer.c Tue Jan 29 16:49:36 2019 +0300
+++ b/njs/njs_lexer.c Tue Jan 29 18:15:03 2019 +0300
@@ -704,10 +704,8 @@ njs_lexer_division(njs_lexer_t *lexer, n
}

if (*p == '*') {
- p++;
-
- if (p < lexer->end && *p == '/') {
- lexer->start = p + 1;
+ if (p + 1 < lexer->end && p[1] == '/') {
+ lexer->start = p + 2;
return NJS_TOKEN_AGAIN;
}
}
diff -r ef39ae753b9e -r 348a34597bab njs/test/njs_interactive_test.c
--- a/njs/test/njs_interactive_test.c Tue Jan 29 16:49:36 2019 +0300
+++ b/njs/test/njs_interactive_test.c Tue Jan 29 18:15:03 2019 +0300
@@ -233,6 +233,23 @@ static njs_interactive_test_t njs_test[
nxt_string("TypeError: Cannot convert object to primitive value\n"
" at main (native)\n") },

+ /* line numbers */
+
+ { nxt_string("/**/(function(){throw Error();})()" ENTER),
+ nxt_string("Error\n"
+ " at anonymous (:1)\n"
+ " at main (native)\n") },
+
+ { nxt_string("/***/(function(){throw Error();})()" ENTER),
+ nxt_string("Error\n"
+ " at anonymous (:1)\n"
+ " at main (native)\n") },
+
+ { nxt_string("/*\n**/(function(){throw Error();})()" ENTER),
+ nxt_string("Error\n"
+ " at anonymous (:2)\n"
+ " at main (native)\n") },
+
};


diff -r ef39ae753b9e -r 348a34597bab njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Jan 29 16:49:36 2019 +0300
+++ b/njs/test/njs_unit_test.c Tue Jan 29 18:15:03 2019 +0300
@@ -28,6 +28,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("1}"),
nxt_string("SyntaxError: Unexpected token \"}\" in 1") },

+ { nxt_string("/***/1/*\n**/"),
+ nxt_string("1") },
+
/* Variable declarations. */

{ nxt_string("var x"),
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed parsing multiline comments.

Dmitry Volyntsev 113 January 29, 2019 10:16AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 99
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready