commit 19a5edf3da4acec32a964ac91c065e121b0a0ec2 from: Omar Polo date: Tue Sep 12 10:14:02 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 - 424803ac446821016c55b334cd85a83aba4d3f37 commit + 19a5edf3da4acec32a964ac91c065e121b0a0ec2 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");