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);
 }
09-14Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe There are probably better things to sort by but title definitely always exists. 2021-09-13Swap-remove tags as they're foundJune McEnroe This makes it even faster. From ~1s on a sqlite3.c amalgamation to ~0.85s. 2021-09-12Replace htagml regex with strncmpJune McEnroe Since ctags only ever produces regular expressions of the form /^re$/ or /^re/ with no other special characters, instead unescape the pattern and simply use strncmp. Running on a sqlite3.c amalgamation, the regex version takes ~37s while the strncmp version takes ~1s, producing identical output. Big win! 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe This fixes badly indented comments. 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe