saait

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

commit b3db791ebe566ca99df34a365df1f2632f2a31c8
parent 0007e983fbd257049d360f1347c4266ac9e83847
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon,  4 Dec 2017 23:27:04 +0100

style: line-wrap some lines

Diffstat:
Msaait.c | 30++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/saait.c b/saait.c @@ -209,7 +209,9 @@ parsevars(const char *s) s++; continue; } - for (keyend = s; keyend > keystart && (keyend[-1] == ' ' || keyend[-1] == '\t'); keyend--) + for (keyend = s; keyend > keystart && + (keyend[-1] == ' ' || keyend[-1] == '\t'); + keyend--) ; /* no variable name: skip */ if (keystart == keyend) @@ -308,7 +310,7 @@ writepage(FILE *fp, const char *filename, struct variable *c, char *s) void usage(void) { - fprintf(stderr, "saait [-c config] [-o outputdir] [-t templatedir] pages...\n"); + fprintf(stderr, "%s [-c config] [-o outputdir] [-t templatedir] pages...\n", argv0); exit(1); } @@ -346,9 +348,11 @@ main(int argc, char *argv[]) for (i = 0; i < LEN(templates); i++) { for (j = 0; j < LEN(templates[i].blocks); j++) { b = &templates[i].blocks[j]; - r = snprintf(file, sizeof(file), "%s/%s", templatedir, b->name); + r = snprintf(file, sizeof(file), "%s/%s", templatedir, + b->name); if (r < 0 || (size_t) r >= sizeof(file)) { - fprintf(stderr, "path truncated: '%s/%s'\n", templatedir, b->name); + fprintf(stderr, "path truncated: '%s/%s'\n", + templatedir, b->name); exit(1); } b->data = readfile(file); @@ -359,9 +363,11 @@ main(int argc, char *argv[]) for (i = 0; i < LEN(templates); i++) { if (!strcmp(templates[i].name, "page")) continue; - r = snprintf(file, sizeof(file), "%s/%s", outputdir, templates[i].name); + r = snprintf(file, sizeof(file), "%s/%s", outputdir, + templates[i].name); if (r < 0 || (size_t) r >= sizeof(file)) { - fprintf(stderr, "path truncated: '%s/%s'\n", outputdir, templates[i].name); + fprintf(stderr, "path truncated: '%s/%s'\n", outputdir, + templates[i].name); exit(1); } templates[i].fp = efopen(file, "wb"); @@ -374,7 +380,8 @@ main(int argc, char *argv[]) c = readconfig(argv[i]); if ((p = strrchr(argv[i], '.'))) - r = snprintf(htmlfile, sizeof(htmlfile), "%.*s.html", (int)(p - argv[i]), argv[i]); + r = snprintf(htmlfile, sizeof(htmlfile), "%.*s.html", + (int)(p - argv[i]), argv[i]); else r = snprintf(htmlfile, sizeof(htmlfile), "%s.html", argv[i]); if (r < 0 || (size_t)r >= sizeof(htmlfile)) { @@ -384,7 +391,8 @@ main(int argc, char *argv[]) /* set htmlfile, but allow to override it */ setvar(&c, newvar("htmlfile", htmlfile), 0); - /* set HTML output filename (with part removed), but allow to override it */ + /* set HTML output filename (with part removed), but allow to + override it */ if ((p = strrchr(htmlfile, '/'))) setvar(&c, newvar("filename", &htmlfile[p - htmlfile + 1]), 0); else @@ -397,9 +405,11 @@ main(int argc, char *argv[]) for (j = 0; j < LEN(templates); j++) { /* TODO: page is a special case for now */ if (!strcmp(templates[j].name, "page")) { - r = snprintf(outputfile, sizeof(outputfile), "%s/%s", outputdir, v->value); + r = snprintf(outputfile, sizeof(outputfile), "%s/%s", + outputdir, v->value); if (r < 0 || (size_t)r >= sizeof(outputfile)) { - fprintf(stderr, "path truncated: '%s/%s'\n", outputdir, v->value); + fprintf(stderr, "path truncated: '%s/%s'\n", + outputdir, v->value); exit(1); }