diff options
author | Konstantin Pavlov <thresh@nginx.com> | 2024-12-19 10:23:57 -0800 |
---|---|---|
committer | Konstantin Pavlov <thresh@nginx.com> | 2024-12-19 10:23:57 -0800 |
commit | d8acad350a52a20918c46c09cb0a0f5479400923 (patch) | |
tree | 7d9c4b64daa60d3ac121743dfa3735c6fc5687a4 /src/nxt_js.c | |
parent | 624debcf17ea7faab01fa841bd4dcd9f308cf306 (diff) | |
parent | 27bde184dedcbf687db2f314c60c037623318a8d (diff) | |
download | unit-1.34.0-1.tar.gz unit-1.34.0-1.tar.bz2 |
Merge tag '1.34.0' into packaging1.34.0-1
Unit 1.34.0 release.
Diffstat (limited to 'src/nxt_js.c')
-rw-r--r-- | src/nxt_js.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/nxt_js.c b/src/nxt_js.c index d46231bd..0482482a 100644 --- a/src/nxt_js.c +++ b/src/nxt_js.c @@ -230,7 +230,7 @@ nxt_js_add_module(nxt_js_conf_t *jcf, nxt_str_t *name, nxt_str_t *text) nxt_js_t * -nxt_js_add_tpl(nxt_js_conf_t *jcf, nxt_str_t *str, nxt_bool_t strz) +nxt_js_add_tpl(nxt_js_conf_t *jcf, nxt_str_t *str, nxt_uint_t flags) { size_t size; u_char *p, *start; @@ -243,13 +243,19 @@ nxt_js_add_tpl(nxt_js_conf_t *jcf, nxt_str_t *str, nxt_bool_t strz) " return "); /* - * Appending a terminating null character if strz is true. + * Append a newline character if newline is true. + * Append a terminating null character if strz is true. */ + static const nxt_str_t newline_str = nxt_string(" + '\\x0A'"); static const nxt_str_t strz_str = nxt_string(" + '\\x00'"); size = func_str.length + str->length + 1; - if (strz) { + if (flags & NXT_TSTR_NEWLINE) { + size += newline_str.length; + } + + if (flags & NXT_TSTR_STRZ) { size += strz_str.length; } @@ -263,7 +269,11 @@ nxt_js_add_tpl(nxt_js_conf_t *jcf, nxt_str_t *str, nxt_bool_t strz) p = nxt_cpymem(p, func_str.start, func_str.length); p = nxt_cpymem(p, str->start, str->length); - if (strz) { + if (flags & NXT_TSTR_NEWLINE) { + p = nxt_cpymem(p, newline_str.start, newline_str.length); + } + + if (flags & NXT_TSTR_STRZ) { p = nxt_cpymem(p, strz_str.start, strz_str.length); } |