diff options
author | John Ankarström <john@ankarstrom.se> | 2021-09-17 20:57:05 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-09-17 20:57:05 +0200 |
commit | 361bb55f01ba28960a8127b0a16c1e7a7a8de61a (patch) | |
tree | ff0479af1c9283c8a0546025022ebc54616a9a75 /maketpl | |
parent | 2810ad72aeb973a898034d6875922284062c5ce0 (diff) | |
download | cforum-361bb55f01ba28960a8127b0a16c1e7a7a8de61a.tar.gz |
Rewrite mktpl script in C
The Perl version didn't handle multiple interpolations on the same line.
Diffstat (limited to 'maketpl')
-rwxr-xr-x | maketpl | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/maketpl b/maketpl deleted file mode 100755 index 7908f3b..0000000 --- a/maketpl +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env perl - -# `maketpl' translates a template file (.t) to a C program (.tc) -# that prints that template with the desired interpolations. - -use strict; -use warnings; - -my $buf; - -while (<STDIN>) { - if (/(.*)\<%=(.+)%\>(.*)/) { - $buf .= $1; - flsh(); - print qq(printf("%s", $2);\n); - if ($3) { - $buf .= "$3\n"; - } - } elsif (/(.*)\<%/) { - my $code; - $buf .= $1; - flsh(); - if (/\<%(.*)%\>(.*)/) { - $code = $1; - $buf .= $2; - $buf .= "\n"; - } else { - /\<%(.*)/; - $code = $1; - while (<STDIN>) { - if (/(.*)%\>(.*)/) { - $code .= $1; - $buf .= $2; - $buf .= "\n"; - last; - } - $code .= $_; - } - } - print $code; - } else { - $buf .= $_; - } -} - -flsh(); - -sub flsh { - return if not $buf; - $buf =~ s/\\/\\\\/g; - $buf =~ s/"/\\"/g; - $buf =~ s/\n/\\n/g; - print qq(printf("$buf");\n); - $buf = ''; -}
\ No newline at end of file |