[njs] Added support for numeric separators (ES12).
details: https://hg.nginx.org/njs/rev/4818a450f4e6 branches: changeset: 1495:4818a450f4e6 user: Valentin Bartenev date: Mon Aug 17 19:55:46 2020 +0300 description: Added support for numeric separators (ES12). diffstat: src/njs_json.c |2 +- src/njs_lexer.c | 10 +++- src/njs_number.c | 42 +- src/njs_number.h |6 +- src/njs_parser.c |4 +- src/njs_string.c |6 +- src/njs_strtod.c | 36 +++- src/njs_strtod.h |3 +- src/test/njs_unit_test.c | 101 ++ 9 files changed, 173 insertions(+), 37 deletions(-) diffs (518 lines): diff -r 10a2c35d53e7 -r 4818a450f4e6 src/njs_json.c --- a/src/njs_json.cMon Aug 17 14:44:29 2020 +0300 +++ b/src/njs_json.cMon Aug 17 19:55:46 2020 +0300 @@ -796,7 +796,7 @@ njs_json_parse_number(njs_json_parse_ctx } start = p; -num = njs_number_dec_parse(, ctx->end); +num = njs_number_dec_parse(, ctx->end, 0); if (p != start) { njs_set_number(value, sign * num); return p; diff -r 10a2c35d53e7 -r 4818a450f4e6 src/njs_lexer.c --- a/src/njs_lexer.c Mon Aug 17 14:44:29 2020 +0300 +++ b/src/njs_lexer.c Mon Aug 17 19:55:46 2020 +0300 @@ -787,7 +787,7 @@ njs_lexer_number(njs_lexer_t *lexer, njs goto illegal_token; } -token->number = njs_number_hex_parse(, lexer->end); +token->number = njs_number_hex_parse(, lexer->end, 1); goto done; } @@ -830,16 +830,20 @@ njs_lexer_number(njs_lexer_t *lexer, njs /* Legacy Octal literals are deprecated. */ -if (*p >= '0' && *p <= '9') { +if ((*p >= '0' && *p <= '9') || *p == '_') { goto illegal_trailer; } } p--; -token->number = njs_number_dec_parse(, lexer->end); +token->number = njs_number_dec_parse(, lexer->end, 1); done: +if (p[-1] == '_') { +p--; +} + lexer->start = (u_char *) p; token->text.length = p - token->text.start; diff -r 10a2c35d53e7 -r 4818a450f4e6 src/njs_number.c --- a/src/njs_number.c Mon Aug 17 14:44:29 2020 +0300 +++ b/src/njs_number.c Mon Aug 17 19:55:46 2020 +0300 @@ -54,9 +54,10 @@ njs_key_to_index(const njs_value_t *valu double -njs_number_dec_parse(const u_char **start, const u_char *end) +njs_number_dec_parse(const u_char **start, const u_char *end, +njs_bool_t literal) { -return njs_strtod(start, end); +return njs_strtod(start, end, literal); } @@ -65,22 +66,27 @@ njs_number_oct_parse(const u_char **star { u_charc; uint64_t num; -const u_char *p; +const u_char *p, *_; p = *start; num = 0; +_ = p - 1; -while (p < end) { +for (; p < end; p++) { /* Values less than '0' become >= 208. */ c = *p - '0'; if (njs_slow_path(c > 7)) { +if (*p == '_' && (p - _) > 1) { +_ = p; +continue; +} + break; } num = num * 8 + c; -p++; } *start = p; @@ -94,22 +100,27 @@ njs_number_bin_parse(const u_char **star { u_charc; uint64_t num; -const u_char *p; +const u_char *p, *_; p = *start; num = 0; +_ = p - 1; -while (p < end) { +for (; p < end; p++) { /* Values less than '0' become >= 208. */ c = *p - '0'; if (njs_slow_path(c > 1)) { +if (*p == '_' && (p - _) > 1) { +_ = p; +continue; +} + break; } num = num * 2 + c; -p++; } *start = p; @@ -119,24 +130,31 @@ njs_number_bin_parse(const u_char **star uint64_t -njs_number_hex_parse(const u_char **start, const u_char *end) +njs_number_hex_parse(const u_char **start, const u_char *end, +njs_bool_t literal) { uint64_t num; njs_int_t n; -const u_char *p; +const u_char *p, *_; p = *start; num = 0; +_ = p - 1; -while (p < end) { +for (; p < end; p++) { n = njs_char_to_hex(*p); + if (njs_slow_path(n < 0)) { +if (literal && *p == '_' && (p - _) > 1) { +_ = p; +continue; +} + break; } num = num * 16 + n; -p++; } *start = p; diff -r 10a2c35d53e7 -r 4818a450f4e6 src/njs_number.h --- a/src/njs_number.h Mon Aug 17 14:44:29 2020 +0300 +++ b/src/njs_number.h Mon Aug 17 19:55:46 2020 +0300 @@ -12,10 +12,12 @@ double njs_key_to_index(const njs_value_t *value); -double njs_number_dec_parse(const u_char **start, const u_char *end); +double njs_number_dec_parse(const u_char **start, const u_char *end, +njs_bool_t literal); uint64_t njs_number_oct_parse(const u_char **start, const u_char *end);
[njs] Unicode case tables updated to version 13.0.0 (March 2020).
details: https://hg.nginx.org/njs/rev/10a2c35d53e7 branches: changeset: 1494:10a2c35d53e7 user: Valentin Bartenev date: Mon Aug 17 14:44:29 2020 +0300 description: Unicode case tables updated to version 13.0.0 (March 2020). diffstat: src/njs_unicode_lower_case.h | 6 +++--- src/njs_unicode_upper_case.h | 4 ++-- src/njs_utf8.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diffs (50 lines): diff -r eebf9e525358 -r 10a2c35d53e7 src/njs_unicode_lower_case.h --- a/src/njs_unicode_lower_case.h Mon Aug 17 11:22:35 2020 + +++ b/src/njs_unicode_lower_case.h Mon Aug 17 14:44:29 2020 +0300 @@ -570,13 +570,13 @@ static const uint32_t njs_unicode_lower 0x0a7a9, 0x0a7a9, 0x00266, 0x0025c, 0x00261, 0x0026c, 0x0026a, 0x0a7af, 0x0029e, 0x00287, 0x0029d, 0x0ab53, 0x0a7b5, 0x0a7b5, 0x0a7b7, 0x0a7b7, 0x0a7b9, 0x0a7b9, 0x0a7bb, 0x0a7bb, 0x0a7bd, 0x0a7bd, 0x0a7bf, 0x0a7bf, -0x0a7c0, 0x0a7c1, 0x0a7c3, 0x0a7c3, 0x0a794, 0x00282, 0x01d8e, 0x0a7c7, -0x0a7c8, 0x0a7c9, 0x0a7ca, 0x0a7cb, 0x0a7cc, 0x0a7cd, 0x0a7ce, 0x0a7cf, +0x0a7c0, 0x0a7c1, 0x0a7c3, 0x0a7c3, 0x0a794, 0x00282, 0x01d8e, 0x0a7c8, +0x0a7c8, 0x0a7ca, 0x0a7ca, 0x0a7cb, 0x0a7cc, 0x0a7cd, 0x0a7ce, 0x0a7cf, 0x0a7d0, 0x0a7d1, 0x0a7d2, 0x0a7d3, 0x0a7d4, 0x0a7d5, 0x0a7d6, 0x0a7d7, 0x0a7d8, 0x0a7d9, 0x0a7da, 0x0a7db, 0x0a7dc, 0x0a7dd, 0x0a7de, 0x0a7df, 0x0a7e0, 0x0a7e1, 0x0a7e2, 0x0a7e3, 0x0a7e4, 0x0a7e5, 0x0a7e6, 0x0a7e7, 0x0a7e8, 0x0a7e9, 0x0a7ea, 0x0a7eb, 0x0a7ec, 0x0a7ed, 0x0a7ee, 0x0a7ef, -0x0a7f0, 0x0a7f1, 0x0a7f2, 0x0a7f3, 0x0a7f4, 0x0a7f5, 0x0a7f6, 0x0a7f7, +0x0a7f0, 0x0a7f1, 0x0a7f2, 0x0a7f3, 0x0a7f4, 0x0a7f6, 0x0a7f6, 0x0a7f7, 0x0a7f8, 0x0a7f9, 0x0a7fa, 0x0a7fb, 0x0a7fc, 0x0a7fd, 0x0a7fe, 0x0a7ff, }; diff -r eebf9e525358 -r 10a2c35d53e7 src/njs_unicode_upper_case.h --- a/src/njs_unicode_upper_case.h Mon Aug 17 11:22:35 2020 + +++ b/src/njs_unicode_upper_case.h Mon Aug 17 14:44:29 2020 +0300 @@ -681,12 +681,12 @@ static const uint32_t njs_unicode_upper 0x0a7b0, 0x0a7b1, 0x0a7b2, 0x0a7b3, 0x0a7b4, 0x0a7b4, 0x0a7b6, 0x0a7b6, 0x0a7b8, 0x0a7b8, 0x0a7ba, 0x0a7ba, 0x0a7bc, 0x0a7bc, 0x0a7be, 0x0a7be, 0x0a7c0, 0x0a7c1, 0x0a7c2, 0x0a7c2, 0x0a7c4, 0x0a7c5, 0x0a7c6, 0x0a7c7, -0x0a7c8, 0x0a7c9, 0x0a7ca, 0x0a7cb, 0x0a7cc, 0x0a7cd, 0x0a7ce, 0x0a7cf, +0x0a7c7, 0x0a7c9, 0x0a7c9, 0x0a7cb, 0x0a7cc, 0x0a7cd, 0x0a7ce, 0x0a7cf, 0x0a7d0, 0x0a7d1, 0x0a7d2, 0x0a7d3, 0x0a7d4, 0x0a7d5, 0x0a7d6, 0x0a7d7, 0x0a7d8, 0x0a7d9, 0x0a7da, 0x0a7db, 0x0a7dc, 0x0a7dd, 0x0a7de, 0x0a7df, 0x0a7e0, 0x0a7e1, 0x0a7e2, 0x0a7e3, 0x0a7e4, 0x0a7e5, 0x0a7e6, 0x0a7e7, 0x0a7e8, 0x0a7e9, 0x0a7ea, 0x0a7eb, 0x0a7ec, 0x0a7ed, 0x0a7ee, 0x0a7ef, -0x0a7f0, 0x0a7f1, 0x0a7f2, 0x0a7f3, 0x0a7f4, 0x0a7f5, 0x0a7f6, 0x0a7f7, +0x0a7f0, 0x0a7f1, 0x0a7f2, 0x0a7f3, 0x0a7f4, 0x0a7f5, 0x0a7f5, 0x0a7f7, 0x0a7f8, 0x0a7f9, 0x0a7fa, 0x0a7fb, 0x0a7fc, 0x0a7fd, 0x0a7fe, 0x0a7ff, }; diff -r eebf9e525358 -r 10a2c35d53e7 src/njs_utf8.c --- a/src/njs_utf8.cMon Aug 17 11:22:35 2020 + +++ b/src/njs_utf8.cMon Aug 17 14:44:29 2020 +0300 @@ -9,7 +9,7 @@ /* * The njs_unicode_lower_case.h and njs_unicode_upper_case.h files are - * files auto-generated from the UnicodeData.txt file version 12.1.0 (May 2019) + * auto-generated from the UnicodeData.txt file version 13.0.0 (March 2020) * provided by Unicode, Inc.: * * ./njs_unicode_lower_case.pl UnicodeData.txt ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[njs] HTTP: fixed location merge.
details: https://hg.nginx.org/njs/rev/eebf9e525358 branches: changeset: 1493:eebf9e525358 user: Dmitry Volyntsev date: Mon Aug 17 11:22:35 2020 + description: HTTP: fixed location merge. diffstat: nginx/ngx_http_js_module.c | 5 + 1 files changed, 5 insertions(+), 0 deletions(-) diffs (14 lines): diff -r 5a80b43b7098 -r eebf9e525358 nginx/ngx_http_js_module.c --- a/nginx/ngx_http_js_module.cThu Aug 13 13:40:36 2020 + +++ b/nginx/ngx_http_js_module.cMon Aug 17 11:22:35 2020 + @@ -3363,5 +3363,10 @@ ngx_http_js_create_loc_conf(ngx_conf_t * static char * ngx_http_js_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) { +ngx_http_js_loc_conf_t *prev = parent; +ngx_http_js_loc_conf_t *conf = child; + +ngx_conf_merge_str_value(conf->content, prev->content, ""); + return NGX_CONF_OK; } ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel