commit 366a61fa0a047dc2cbf70b4f0d6da0008bb846ee
parent 8b073bb76dcaad5e7029405e91918108e86f2b86
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 5 Jan 2020 23:55:42 +0100
make it easier to debug for which page a variable is undefined
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/saait.c b/saait.c
@@ -303,7 +303,8 @@ xmlencode(const char *s, FILE *fp)
}
void
-writepage(FILE *fp, const char *name, struct variable *c, char *s)
+writepage(FILE *fp, const char *name, const char *forname,
+ struct variable *c, char *s)
{
FILE *fpin;
struct variable *v;
@@ -351,8 +352,9 @@ writepage(FILE *fp, const char *name, struct variable *c, char *s)
key[keylen] = tmpc; /* restore NUL terminator to original */
if (!v) {
- fprintf(stderr, "%s:%zu: error: undefined variable: '%.*s'\n",
- name, linenr, (int)keylen, key);
+ fprintf(stderr, "%s:%zu: error: undefined variable: '%.*s'%s%s\n",
+ name, linenr, (int)keylen, key,
+ forname ? " for " : "", forname ? forname : "");
exit(1);
}
@@ -493,7 +495,7 @@ main(int argc, char *argv[])
/* header */
b = &templates[i].blocks[BlockHeader];
if (b->name)
- writepage(templates[i].fp, b->name, NULL, b->data);
+ writepage(templates[i].fp, b->name, NULL, NULL, b->data);
}
/* pages */
@@ -546,14 +548,17 @@ main(int argc, char *argv[])
for (k = 0; k < LEN(templates[j].blocks); k++) {
b = &templates[j].blocks[k];
if (b->name)
- writepage(templates[j].fp, b->name, c, b->data);
+ writepage(templates[j].fp,
+ b->name, argv[i], c,
+ b->data);
}
fclose(templates[j].fp);
} else {
if (!doindex)
continue; /* do not include in index */
b = &templates[j].blocks[BlockItem];
- writepage(templates[j].fp, b->name, c, b->data);
+ writepage(templates[j].fp, b->name, argv[i], c,
+ b->data);
}
}
freevars(c);
@@ -565,7 +570,7 @@ main(int argc, char *argv[])
continue;
b = &templates[i].blocks[BlockFooter];
if (b->name)
- writepage(templates[i].fp, b->name, NULL, b->data);
+ writepage(templates[i].fp, b->name, NULL, NULL, b->data);
}
return 0;