commit 279f742de00c9d81cb53a5442d3c179091191cc7 from: Omar Polo date: Tue Sep 12 10:25:03 2023 UTC template: join subsequent tp_puts() calls This greatly reduces the number of tp_puts() calls: gotwebd' pages.tmpl goes from 444 to 190. Otherwise, this doesn't produce other observable changes. commit - 1066c216d10ab00c41500809f448f0ba90ae060d commit + 279f742de00c9d81cb53a5442d3c179091191cc7 blob - e626a5c1982cf4b49415b877bfca979ec3c3ab01 blob + c97478128fa19c9cddcf687a802db929cfa6bd36 --- template/parse.y +++ template/parse.y @@ -89,7 +89,7 @@ typedef struct { %token DEFINE ELSE END ERROR FINALLY FOR IF INCLUDE PRINTF %token RENDER TQFOREACH UNSAFE URLESCAPE WHILE %token STRING -%type string +%type string nstring %type stringy %% @@ -137,7 +137,7 @@ verbatims : /* empty */ | verbatims verbatim ; -raw : STRING { +raw : nstring { dbg(); fprintf(fp, "if ((tp_ret = tp->tp_puts(tp, "); printq($1); @@ -290,6 +290,15 @@ finally : '{' FINALLY '}' { } verbatims ; +nstring : STRING nstring { + if (asprintf(&$$, "%s%s", $1, $2) == -1) + err(1, "asprintf"); + free($1); + free($2); + } + | STRING + ; + string : STRING string { if (asprintf(&$$, "%s %s", $1, $2) == -1) err(1, "asprintf");