From 4ca7853b000048514f5bf18391db2e66f65d1377 Mon Sep 17 00:00:00 2001 From: wrmr Date: Sat, 9 Nov 2024 02:21:35 -0500 Subject: add strv_next --- parse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'parse.c') 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); -- cgit 1.4.1-2-gfad0