summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-01-25 03:17:02 -0500
committerJune McEnroe <june@causal.agency>2019-01-25 03:17:02 -0500
commitc4c4de69234e6b934c6e38f7527b4711964b8af5 (patch)
tree0af663e4bd6c5a9e4bf699da5882da8fd7f26a10
parentUse memmem in place of strnstr (diff)
downloadcatgirl-c4c4de69234e6b934c6e38f7527b4711964b8af5.tar.gz
catgirl-c4c4de69234e6b934c6e38f7527b4711964b8af5.zip
Use getline in place of fgetln
-rw-r--r--log.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/log.c b/log.c
index 0b7e386..579e99b 100644
--- a/log.c
+++ b/log.c
@@ -132,12 +132,14 @@ void logReplay(struct Tag tag) {
 	FILE *file = logFile(tag, time);
 	rewind(file);
 
-	size_t len;
-	char *line;
-	while (NULL != (line = fgetln(file, &len))) {
+	char *line = NULL;
+	size_t cap = 0;
+	ssize_t len;
+	while (0 < (len = getline(&line, &cap, file))) {
+		if (len < 1 + StampLen + 2 + 1) continue;
 		line[len - 1] = '\0';
-		if (len > 1 + StampLen + 2) line = &line[1 + StampLen + 2];
-		uiFmt(tag, UICold, "\3%d%s", IRCGray, line);
+		uiFmt(tag, UICold, "\3%d%s", IRCGray, &line[1 + StampLen + 2]);
 	}
 	if (ferror(file)) err(EX_IOERR, "%s", tag.name);
+	free(line);
 }
1-01-19 23:23:59 -0500'>2021-01-19Escape \ and / in mtags search patternsJune McEnroe 2021-01-20Use mtags in source-filterJune McEnroe 2021-01-19Add mtags to generate tags for make and mdocJune McEnroe 2021-01-19Map tags to IDs using only [[:alnum:]-._]June McEnroe 2021-01-19Don't use a pager if reading standard inputJune McEnroe 2021-01-19Support BSD make syntax and match *.amJune McEnroe These don't really go together, but... 2021-01-19Match tab following escaped newline in make assignmentsJune McEnroe Otherwise it ends up going into Shell state. 2021-01-18Allow matching lexers using first input lineJune McEnroe