Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # HG changeset patch
- # User Dmitry Volyntsev <xeioex@nginx.com>
- # Date 1551146886 -28800
- # Node ID dd4597e5962e7504a1346bfd392dc39af739ddd4
- # Parent d498378197210c8f226f32018031f054150785e5
- Improved checking filename is not empty.
- file->start can be non NULL for empty string.
- diff -r d49837819721 -r dd4597e5962e njs/njs_parser.c
- --- a/njs/njs_parser.c Mon Feb 25 19:00:56 2019 +0300
- +++ b/njs/njs_parser.c Tue Feb 26 10:08:06 2019 +0800
- @@ -233,7 +233,7 @@ njs_parser_scope_begin(njs_vm_t *vm, njs
- scope->values[0] = values;
- scope->values[1] = NULL;
- - if (parser->lexer->file.start != NULL) {
- + if (parser->lexer->file.length != 0) {
- ret = njs_name_copy(vm, &scope->file, &parser->lexer->file);
- if (nxt_slow_path(ret != NXT_OK)) {
- return NXT_ERROR;
- @@ -2758,7 +2758,7 @@ njs_parser_trace_handler(nxt_trace_t *tr
- if (vm->parser != NULL) {
- lexer = vm->parser->lexer;
- - if (lexer->file.start != NULL) {
- + if (lexer->file.length != 0) {
- njs_internal_error(vm, "%s in %V:%uD", start, &lexer->file,
- lexer->line);
- } else {
- @@ -2795,7 +2795,7 @@ njs_parser_scope_error(njs_vm_t *vm, njs
- p = end - width;
- }
- - if (file->start != NULL) {
- + if (file->length != 0) {
- p = nxt_sprintf(p, end, " in %V:%uD", file, line);
- } else {
- # HG changeset patch
- # User hongzhidao <hongzhidao@gmail.com>
- # Date 1551147113 -28800
- # Node ID 84cbda896e475a7cd0fc360753eff5df19faec5a
- # Parent dd4597e5962e7504a1346bfd392dc39af739ddd4
- Improved parser syntax error.
- diff -r dd4597e5962e -r 84cbda896e47 njs/njs_parser.c
- --- a/njs/njs_parser.c Tue Feb 26 10:08:06 2019 +0800
- +++ b/njs/njs_parser.c Tue Feb 26 10:11:53 2019 +0800
- @@ -279,30 +279,28 @@ njs_parser_statement_chain(njs_vm_t *vm,
- token = njs_parser_statement(vm, parser, token);
- - if (nxt_fast_path(token > NJS_TOKEN_ILLEGAL)) {
- -
- - if (parser->node != NULL) {
- - /* The statement is not empty block or just semicolon. */
- -
- - node = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT);
- - if (nxt_slow_path(node == NULL)) {
- - return NJS_TOKEN_ERROR;
- - }
- -
- - node->left = last;
- - node->right = parser->node;
- - *dest = node;
- -
- - while (token == NJS_TOKEN_SEMICOLON) {
- - token = njs_parser_token(parser);
- - if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
- - break;
- - }
- + if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
- + return njs_parser_unexpected_token(vm, parser, token);
- + }
- +
- + if (parser->node != NULL) {
- + /* The statement is not empty block or just semicolon. */
- +
- + node = njs_parser_node_new(vm, parser, NJS_TOKEN_STATEMENT);
- + if (nxt_slow_path(node == NULL)) {
- + return NJS_TOKEN_ERROR;
- + }
- +
- + node->left = last;
- + node->right = parser->node;
- + *dest = node;
- +
- + while (token == NJS_TOKEN_SEMICOLON) {
- + token = njs_parser_token(parser);
- + if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
- + break;
- }
- }
- -
- - } else if (!njs_is_error(&vm->retval)) {
- - (void) njs_parser_unexpected_token(vm, parser, token);
- }
- return token;
- @@ -2812,6 +2810,10 @@ njs_parser_lexer_error(njs_vm_t *vm, njs
- {
- va_list args;
- + if (njs_is_error(&vm->retval)) {
- + return;
- + }
- +
- va_start(args, fmt);
- njs_parser_scope_error(vm, parser->scope, type, parser->lexer->line, fmt,
- args);
- # HG changeset patch
- # User hongzhidao <hongzhidao@gmail.com>
- # Date 1551173402 -28800
- # Node ID 22936042fb972c0c00490167e7a61f2c6af502a9
- # Parent 84cbda896e475a7cd0fc360753eff5df19faec5a
- Improved parser scope filename.
- diff -r 84cbda896e47 -r 22936042fb97 njs/njs_parser.c
- --- a/njs/njs_parser.c Tue Feb 26 10:11:53 2019 +0800
- +++ b/njs/njs_parser.c Tue Feb 26 17:30:02 2019 +0800
- @@ -164,9 +164,9 @@ njs_parser(njs_vm_t *vm, njs_parser_t *p
- static njs_ret_t
- njs_parser_scope_begin(njs_vm_t *vm, njs_parser_t *parser, njs_scope_t type)
- {
- - nxt_int_t ret;
- nxt_uint_t nesting;
- nxt_array_t *values;
- + njs_lexer_t *lexer;
- njs_parser_scope_t *scope, *parent;
- nesting = 0;
- @@ -233,11 +233,10 @@ njs_parser_scope_begin(njs_vm_t *vm, njs
- scope->values[0] = values;
- scope->values[1] = NULL;
- - if (parser->lexer->file.length != 0) {
- - ret = njs_name_copy(vm, &scope->file, &parser->lexer->file);
- - if (nxt_slow_path(ret != NXT_OK)) {
- - return NXT_ERROR;
- - }
- + lexer = parser->lexer;
- +
- + if (lexer->file.length != 0) {
- + nxt_file_basename(&lexer->file, &scope->file);
- }
- parent = parser->scope;
- diff -r 84cbda896e47 -r 22936042fb97 njs/njs_shell.c
- --- a/njs/njs_shell.c Tue Feb 26 10:11:53 2019 +0800
- +++ b/njs/njs_shell.c Tue Feb 26 17:30:02 2019 +0800
- @@ -218,7 +218,6 @@ main(int argc, char **argv)
- if (opts.file != NULL) {
- vm_options.file.start = (u_char *) opts.file;
- vm_options.file.length = strlen(opts.file);
- - nxt_file_basename(&vm_options.file, &vm_options.file);
- } else {
- vm_options.file = nxt_string_value("shell");
- # HG changeset patch
- # User hongzhidao <hongzhidao@gmail.com>
- # Date 1551173579 -28800
- # Node ID 9f0a23b7d8a5ddb2c7deccff8f00dd1a570a4d03
- # Parent 22936042fb972c0c00490167e7a61f2c6af502a9
- Style.
- diff -r 22936042fb97 -r 9f0a23b7d8a5 njs/njs_disassembler.c
- --- a/njs/njs_disassembler.c Tue Feb 26 17:30:02 2019 +0800
- +++ b/njs/njs_disassembler.c Tue Feb 26 17:32:59 2019 +0800
- @@ -412,39 +412,39 @@ njs_disassemble(u_char *start, u_char *e
- n = nxt_nitems(code_names);
- do {
- - if (operation == code_name->operation) {
- - name = &code_name->name;
- + if (operation == code_name->operation) {
- + name = &code_name->name;
- - if (code_name->size == sizeof(njs_vmcode_3addr_t)) {
- - code3 = (njs_vmcode_3addr_t *) p;
- + if (code_name->size == sizeof(njs_vmcode_3addr_t)) {
- + code3 = (njs_vmcode_3addr_t *) p;
- - printf("%05zd %*s %04zX %04zX %04zX\n",
- - p - start, (int) name->length, name->start,
- - (size_t) code3->dst, (size_t) code3->src1,
- - (size_t) code3->src2);
- + printf("%05zd %*s %04zX %04zX %04zX\n",
- + p - start, (int) name->length, name->start,
- + (size_t) code3->dst, (size_t) code3->src1,
- + (size_t) code3->src2);
- - } else if (code_name->size == sizeof(njs_vmcode_2addr_t)) {
- - code2 = (njs_vmcode_2addr_t *) p;
- + } else if (code_name->size == sizeof(njs_vmcode_2addr_t)) {
- + code2 = (njs_vmcode_2addr_t *) p;
- - printf("%05zd %*s %04zX %04zX\n",
- - p - start, (int) name->length, name->start,
- - (size_t) code2->dst, (size_t) code2->src);
- + printf("%05zd %*s %04zX %04zX\n",
- + p - start, (int) name->length, name->start,
- + (size_t) code2->dst, (size_t) code2->src);
- - } else if (code_name->size == sizeof(njs_vmcode_1addr_t)) {
- - code1 = (njs_vmcode_1addr_t *) p;
- + } else if (code_name->size == sizeof(njs_vmcode_1addr_t)) {
- + code1 = (njs_vmcode_1addr_t *) p;
- - printf("%05zd %*s %04zX\n",
- - p - start, (int) name->length, name->start,
- - (size_t) code1->index);
- - }
- + printf("%05zd %*s %04zX\n",
- + p - start, (int) name->length, name->start,
- + (size_t) code1->index);
- + }
- - p += code_name->size;
- + p += code_name->size;
- - goto next;
- - }
- + goto next;
- + }
- - code_name++;
- - n--;
- + code_name++;
- + n--;
- } while (n != 0);
- # HG changeset patch
- # User hongzhidao <hongzhidao@gmail.com>
- # Date 1551147554 -28800
- # Node ID bf1ac9f4a61dbb8bfef2b63e8b226c05cbfe9980
- # Parent 9f0a23b7d8a5ddb2c7deccff8f00dd1a570a4d03
- Refactored njs_value_index().
- diff -r 9f0a23b7d8a5 -r bf1ac9f4a61d njs/njs_string.c
- --- a/njs/njs_string.c Tue Feb 26 17:32:59 2019 +0800
- +++ b/njs/njs_string.c Tue Feb 26 10:19:14 2019 +0800
- @@ -4313,22 +4313,19 @@ uri_error:
- static nxt_int_t
- njs_values_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
- {
- + u_char *start;
- njs_value_t *value;
- value = data;
- - if (lhq->key.length == sizeof(njs_value_t)
- - && memcmp(lhq->key.start, value, sizeof(njs_value_t)) == 0)
- - {
- - return NXT_OK;
- + if (lhq->key.length == sizeof(njs_value_t)) {
- + start = (u_char *) value;
- +
- + } else {
- + start = value->long_string.data->start;
- }
- - if (njs_is_string(value)
- - && value->long_string.size == lhq->key.length
- - && memcmp(value->long_string.data->start, lhq->key.start,
- - lhq->key.length)
- - == 0)
- - {
- + if (memcmp(lhq->key.start, start, lhq->key.length) == 0) {
- return NXT_OK;
- }
- @@ -4358,18 +4355,22 @@ njs_value_index(njs_vm_t *vm, const njs_
- u_char *start;
- uint32_t value_size, size, length;
- nxt_int_t ret;
- + nxt_bool_t long_string;
- njs_value_t *value;
- njs_string_t *string;
- nxt_lvlhsh_t *values_hash;
- nxt_lvlhsh_query_t lhq;
- - if (src->type != NJS_STRING || src->short_string.size != NJS_STRING_LONG) {
- + long_string = src->type == NJS_STRING
- + && src->short_string.size == NJS_STRING_LONG;
- +
- + if (long_string) {
- + size = src->long_string.size;
- + start = src->long_string.data->start;
- +
- + } else {
- size = sizeof(njs_value_t);
- start = (u_char *) src;
- -
- - } else {
- - size = src->long_string.size;
- - start = src->long_string.data->start;
- }
- lhq.key_hash = nxt_djb_hash(start, size);
- @@ -4386,7 +4387,7 @@ njs_value_index(njs_vm_t *vm, const njs_
- } else {
- value_size = 0;
- - if (start != (u_char *) src) {
- + if (long_string) {
- /* Long string value is allocated together with string. */
- value_size = sizeof(njs_value_t) + sizeof(njs_string_t);
- @@ -4406,7 +4407,7 @@ njs_value_index(njs_vm_t *vm, const njs_
- *value = *src;
- - if (start != (u_char *) src) {
- + if (long_string) {
- string = (njs_string_t *) ((u_char *) value + sizeof(njs_value_t));
- value->long_string.data = string;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement