saait

Simple static page generator
git clone https://git.sinitax.com/codemadness/saait
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit e75d8cfb365e36512e26cc62f6246d1dcd8500e1
parent 0f9615a28ddc062de97bcc89170cc7c94ca15f3b
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun,  5 Jan 2020 23:37:08 +0100

improve some comments

Diffstat:
Msaait.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/saait.c b/saait.c @@ -303,7 +303,7 @@ xmlencode(const char *s, FILE *fp) } void -writepage(FILE *fp, const char *file, struct variable *c, char *s) +writepage(FILE *fp, const char *name, struct variable *c, char *s) { FILE *fpin; struct variable *v; @@ -344,13 +344,15 @@ writepage(FILE *fp, const char *file, struct variable *c, char *s) tmpc = key[keylen]; key[keylen] = '\0'; + /* lookup variable in config, if no config or not found look in + global config */ if (!c || !(v = getvar(c, key))) v = getvar(global, key); key[keylen] = tmpc; /* restore NUL terminator to original */ if (!v) { fprintf(stderr, "%s:%zu: error: undefined variable: '%.*s'\n", - file, line + 1, (int)keylen, key); + name, line + 1, (int)keylen, key); exit(1); } @@ -365,7 +367,7 @@ writepage(FILE *fp, const char *file, struct variable *c, char *s) if (!v->value[0]) break; fpin = efopen(v->value, "rb"); - catfile(fpin, v->value, fp, file); + catfile(fpin, v->value, fp, name); fclose(fpin); break; } @@ -474,7 +476,7 @@ main(int argc, char *argv[]) } closedir(bdir); - /* header */ + /* open output files for templates and write header, except for "page" */ for (i = 0; i < templateslen; i++) { /* "page" is a special case */ if (!strcmp(templates[i].name, "page")) @@ -487,6 +489,8 @@ main(int argc, char *argv[]) exit(1); } templates[i].fp = efopen(file, "wb"); + + /* header */ b = &templates[i].blocks[BlockHeader]; if (b->name) writepage(templates[i].fp, b->name, NULL, b->data); @@ -555,6 +559,7 @@ main(int argc, char *argv[]) freevars(c); } + /* write footer, except for "page" */ for (i = 0; i < templateslen; i++) { if (!strcmp(templates[i].name, "page")) continue;