commit d28713dbf90ca19706036b85e548dfdb4069b206 from: Omar Polo via: Thomas Adam date: Tue Sep 12 21:34:33 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 - fdd79f2f3fc3c04e0d548d15436f36fc7d39bb52 commit + d28713dbf90ca19706036b85e548dfdb4069b206 blob - 1e6a9fd07ea3c0e471801ffd54afd0a5773dc68c blob + 4aee74ee52af6f9230f3ed9bf0e1446d58e75dd8 --- template/parse.y +++ template/parse.y @@ -91,7 +91,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 %% @@ -139,7 +139,7 @@ verbatims : /* empty */ | verbatims verbatim ; -raw : STRING { +raw : nstring { dbg(); fprintf(fp, "if ((tp_ret = tp->tp_puts(tp, "); printq($1); @@ -292,6 +292,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");