[njs] Fixed AST printing with long strings values.

Dmitry Volyntsev xeioex at nginx.com
Fri Jun 5 11:59:54 UTC 2020


details:   https://hg.nginx.org/njs/rev/43de01740782
branches:  
changeset: 1423:43de01740782
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Jun 05 11:40:42 2020 +0000
description:
Fixed AST printing with long strings values.

The issue was introduced in d255e73aed3b.

diffstat:

 src/njs_parser.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (20 lines):

diff -r c1e3fd0d24fd -r 43de01740782 src/njs_parser.c
--- a/src/njs_parser.c	Wed Jun 03 18:40:10 2020 +0000
+++ b/src/njs_parser.c	Fri Jun 05 11:40:42 2020 +0000
@@ -8368,12 +8368,14 @@ njs_parser_serialize_tree(njs_chb_t *cha
             njs_parser_serialize_indent(chain, indent);
 
             if (node->token_type == NJS_TOKEN_NUMBER) {
-                njs_chb_sprintf(chain, 32, " \"value\": %f\n",
+                njs_chb_sprintf(chain, 32, " \"value\": %f",
                                 njs_number(&node->u.value));
 
             } else {
                 njs_string_get(&node->u.value, &str);
-                njs_chb_sprintf(chain, 32, " \"value\": \"%V\"\n", &str);
+                njs_chb_append_literal(chain, " \"value\": \"");
+                njs_chb_append_str(chain, &str);
+                njs_chb_append_literal(chain, "\"");
             }
 
             break;


More information about the nginx-devel mailing list