From 13927fc6083c3d134e456ccfafb953c6cea17662 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 27 Feb 2016 16:21:30 +0100 Subject: various improvements - pledge tools and add define to enable it on platforms that support it, currently only OpenBSD 5.9+ - separate getline and parseline functionality. - use murmur3 hash instead of jenkins1: faster and less collisions. - make some error messages a bit more clear, for example with path truncation. - some small cleanups, move printutf8pad to util. --- sfeed_frames.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sfeed_frames.c') diff --git a/sfeed_frames.c b/sfeed_frames.c index 57efdf3..8674678 100644 --- a/sfeed_frames.c +++ b/sfeed_frames.c @@ -138,13 +138,15 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) } fputs("\n", fpitems); - while (parseline(&line, &linesize, fields, fpin) > 0) { + while (getline(&line, &linesize, fpin) > 0) { + if (!parseline(line, fields)) + break; /* write content */ if (!(namelen = normalizepath(fields[FieldTitle], name, sizeof(name)))) continue; r = snprintf(filepath, sizeof(filepath), "%s/%s.html", dirpath, name); if (r == -1 || (size_t)r >= sizeof(filepath)) - errx(1, "snprintf: path truncation"); + errx(1, "snprintf: path truncation: '%s/%s.html'", dirpath, name); /* content file doesn't exist yet and has write access */ if (access(filepath, F_OK) != 0) { @@ -215,6 +217,9 @@ main(int argc, char *argv[]) int i; struct feed *f; + if (pledge("stdio rpath wpath cpath", NULL) == -1) + err(1, "pledge"); + if (!(feeds = calloc(argc, sizeof(struct feed *)))) err(1, "calloc"); -- cgit v1.2.3