summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_tstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nxt_tstr.c')
-rw-r--r--src/nxt_tstr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nxt_tstr.c b/src/nxt_tstr.c
index 50df4c47..36d77e69 100644
--- a/src/nxt_tstr.c
+++ b/src/nxt_tstr.c
@@ -80,16 +80,17 @@ nxt_tstr_compile(nxt_tstr_state_t *state, const nxt_str_t *str,
{
u_char *p;
nxt_tstr_t *tstr;
- nxt_bool_t strz;
+ nxt_bool_t strz, newline;
strz = (flags & NXT_TSTR_STRZ) != 0;
+ newline = (flags & NXT_TSTR_NEWLINE) != 0;
tstr = nxt_mp_get(state->pool, sizeof(nxt_tstr_t));
if (nxt_slow_path(tstr == NULL)) {
return NULL;
}
- tstr->str.length = str->length + strz;
+ tstr->str.length = str->length + newline + strz;
tstr->str.start = nxt_mp_nget(state->pool, tstr->str.length);
if (nxt_slow_path(tstr->str.start == NULL)) {
@@ -98,6 +99,10 @@ nxt_tstr_compile(nxt_tstr_state_t *state, const nxt_str_t *str,
p = nxt_cpymem(tstr->str.start, str->start, str->length);
+ if (newline) {
+ *p++ = '\n';
+ }
+
if (strz) {
*p = '\0';
}
@@ -114,7 +119,7 @@ nxt_tstr_compile(nxt_tstr_state_t *state, const nxt_str_t *str,
nxt_tstr_str(tstr, &tpl);
- tstr->u.js = nxt_js_add_tpl(state->jcf, &tpl, strz);
+ tstr->u.js = nxt_js_add_tpl(state->jcf, &tpl, flags);
if (nxt_slow_path(tstr->u.js == NULL)) {
return NULL;
}