Introduction
Introduction Statistics Contact Development Disclaimer Help
improve some comments - saait - the most boring static page generator
git clone git://git.codemadness.org/saait
Log
Files
Refs
README
LICENSE
---
commit e75d8cfb365e36512e26cc62f6246d1dcd8500e1
parent 0f9615a28ddc062de97bcc89170cc7c94ca15f3b
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 5 Jan 2020 23:37:08 +0100
improve some comments
Diffstat:
M saait.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,…
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: '%…
- 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, c…
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;
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.