stacinhtml

Static C in HTML - simple static site generator
git clone git://git.kocotian.pl/stacinhtml.git
Log | Files | Refs | README | LICENSE

commit 774a2496e4544996ea9eedc2c054ff0262617789
parent 13e2a3498a053ccda4d48eeb5dd28659b4ba6814
Author: kocotian <kocotian@kocotian.pl>
Date:   Thu, 25 Mar 2021 14:09:15 +0100

Variables declaration moved to main()

Diffstat:
Mcompile.c | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/compile.c b/compile.c @@ -296,12 +296,6 @@ main(int argc, char *argv[]) /* Writing beginning of content() */ write(outputfd, "#include <assemble.h>\nvoid content(void) {", 42); - /* Declaring variables */ - for (viter = 0; viter < vss; ++viter) - dprintf(outputfd, "DECLVAR(%.*s, \"%.*s\"); ", - vs[viter].name.len, vs[viter].name.data, - vs[viter].value.len, vs[viter].value.data); - /* And after that, generating C code to output */ generateC(outputfd, input); @@ -313,9 +307,20 @@ main(int argc, char *argv[]) template(outputfd, getVariableByName("template")->value); STACKPOP(); + /* main() beginning */ write(outputfd, "\nint main(void) {\n\t", 19); + + /* Declaring variables */ + for (viter = 0; viter < vss; ++viter) + dprintf(outputfd, "DECLVAR(%.*s, \"%.*s\"); ", + vs[viter].name.len, vs[viter].name.data, + vs[viter].value.len, vs[viter].value.data); + + /* calling function */ caller = Striden($(template)); write(outputfd, caller.data, caller.len); + + /* main() ending */ write(outputfd, "();\n}\n", 6); /* Closing an output */