Welcome! Log In Create A New Profile

Advanced

[njs] Fixed division token in lexer.

Dmitry Volyntsev
August 21, 2019 09:34AM
details: https://hg.nginx.org/njs/rev/4cc08cb772a2
branches:
changeset: 1138:4cc08cb772a2
user: hongzhidao <hongzhidao@gmail.com>
date: Tue Aug 20 22:59:38 2019 -0400
description:
Fixed division token in lexer.

diffstat:

src/njs_lexer.c | 11 +++++++----
src/test/njs_unit_test.c | 3 +++
2 files changed, 10 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r 13161c0357e4 -r 4cc08cb772a2 src/njs_lexer.c
--- a/src/njs_lexer.c Tue Aug 20 20:51:39 2019 +0300
+++ b/src/njs_lexer.c Tue Aug 20 22:59:38 2019 -0400
@@ -504,7 +504,7 @@ njs_lexer_next_token(njs_lexer_t *lexer,
token = njs_lexer_division(lexer, token);

if (token != NJS_TOKEN_AGAIN) {
- return token;
+ goto done;
}

continue;
@@ -557,8 +557,7 @@ njs_lexer_next_token(njs_lexer_t *lexer,
/* Fall through. */

default:
- lt->text.length = lexer->start - lt->text.start;
- return token;
+ goto done;
}

multi:
@@ -566,9 +565,13 @@ njs_lexer_next_token(njs_lexer_t *lexer,
return njs_lexer_multi(lexer, lt, token, n, multi);
}

+ token = NJS_TOKEN_END;
+
+done:
+
lt->text.length = lexer->start - lt->text.start;

- return NJS_TOKEN_END;
+ return token;
}


diff -r 13161c0357e4 -r 4cc08cb772a2 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Tue Aug 20 20:51:39 2019 +0300
+++ b/src/test/njs_unit_test.c Tue Aug 20 22:59:38 2019 -0400
@@ -66,6 +66,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("var \n a, \n b; b"),
njs_str("undefined") },

+ { njs_str("var a / ="),
+ njs_str("SyntaxError: Unexpected token \"/\" in 1") },
+
{ njs_str("var a = 1; var b; a"),
njs_str("1") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed division token in lexer.

Dmitry Volyntsev 95 August 21, 2019 09:34AM



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

Online Users

Guests: 94
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