summary refs log tree commit diff
path: root/parse.c
diff options
context:
space:
mode:
authorwrmr2024-11-09 02:21:35 -0500
committerwrmr2024-11-09 02:21:35 -0500
commit4ca7853b000048514f5bf18391db2e66f65d1377 (patch)
treecbb4450195c2ec813fc7689fd62a8524a657c8c5 /parse.c
parent2780add3f90c284cbb08f2b3a2ad83aeb472d4e0 (diff)
add strv_next
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index afa8008..7af7e52 100644
--- a/parse.c
+++ b/parse.c
@@ -27,6 +27,7 @@ int parse_plain(struct doc *d, const str_t *b) {
 	doc_init(d);
 	strv_t ln, buf = (strv_t) { b->buf, b->sz };
 	while (strv_split(&buf, '\n', &ln)) {
+		if (ln.n > 0 && ln.s[ln.n - 1] == '\r') ln.n--;
 		struct doc_line *l = doc_line_at(d, d->latest);
 		for (size_t j = 1; j + 2 < ln.n; j++) {
 			if (ln.s[j] == ':' && ln.s[j + 1] == '/' && ln.s[j + 2] == '/') {
@@ -58,7 +59,7 @@ int parse_gophermap_line(struct doc *d, strv_t ln) {
 		strv_t host;
 		strv_t port;
 	} bits;
-	bits.item_type = *(ln.s++); ln.n++;
+	bits.item_type = strv_next(&ln);
 	strv_split(&ln, '\t', &bits.dstr);
 	strv_split(&ln, '\t', &bits.sel);
 	strv_split(&ln, '\t', &bits.host);