summary refs log tree commit diff stats
path: root/neols.c
diff options
context:
space:
mode:
authorkaa <kaa@disroot.org>2023-07-09 09:08:23 -0700
committerkaa <kaa@disroot.org>2023-07-09 09:08:23 -0700
commitbaee5248699451f570f6fdfe13ed53e4fe6e9f65 (patch)
tree20fced40766b3445a8020dc69c60055c26e981c2 /neols.c
parentd72126cc5efc1cc5cca2de8960b13a24fee1c7e2 (diff)
downloadneocities-baee5248699451f570f6fdfe13ed53e4fe6e9f65.tar.gz
As it turns out, getline() is a POSIX extension, not included in Windows tcc or MinGW.
Diffstat (limited to 'neols.c')
-rw-r--r--neols.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/neols.c b/neols.c
index 01ce98c..a288fee 100644
--- a/neols.c
+++ b/neols.c
@@ -1,7 +1,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "shared.h"
 
+/* A majority of lines in files.json
+are less than 80 characters long. */
+#define GUESS 80
 /* Each informative line has 6 spaces,
 a quote, then the data type, then a quote,
 then a colon, then a space, then a quote,
@@ -93,15 +97,15 @@ main(int argc, char **argv)
 		else
 			dir = argv[i];
 	}
-	char *line = NULL;
+	char *line;
 	/* The various statistics related to each entry are stored,
 	one entry at a time. A path may be any size, so each line need
 	be handled by realloc. */
 	char *path = NULL, *updated_at = NULL, *sha1_hash = NULL;
 	int is_directory = 0, size = 0;
-	int len;
-	unsigned long line_size = 0;
-	while ((len = getline(&line, &line_size, in)) > 0) {
+	int end, len;
+	for (end = 0; ! end;) {
+		line = storeline(in, &end, &len, GUESS);
 		/* Only on lines terminating an entry, '}' is the
 		fifth character. The ninth character of each data
 		line is unique. */
@@ -139,7 +143,6 @@ main(int argc, char **argv)
 		} else if (line[8] == 'h') {
 			sha1_hash = line;
 		}
-		line = NULL;
 	}
 	return 0;
 }