sacc

sacc (saccomys): simple gopher client.
Log | Files | Refs | LICENSE

commit 43803bed9713d10bf08e93ca0a48298be15e9cdf
parent 3d2081c17810cae6607b3a265f848e5031002d0a
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sun, 19 Aug 2018 16:43:40 +0200

Fix regression from 3d2081c, correctly handle '\n' ending lines

Diffstat:
sacc.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sacc.c b/sacc.c @@ -287,7 +287,7 @@ pickfield(char **raw, const char *sep) { char *c, *f = *raw; - for (c = *raw; *c && strchr(sep, *c) == NULL; ++c) + for (c = *raw; *c && !strchr(sep, *c); ++c) ; *c = '\0'; @@ -306,10 +306,12 @@ invaliditem(char *raw) if (c == '\t') ++tabs; } - if (c) + if (tabs < 3) { *raw++ = '\0'; + return raw; + } - return (tabs >= 3) ? NULL : raw; + return NULL; } static void @@ -331,10 +333,9 @@ molditem(Item *item, char **raw) item->selector = pickfield(raw, "\t"); item->host = pickfield(raw, "\t"); item->port = pickfield(raw, "\t\r"); - while (*raw[0] != '\0') - ++*raw; - if (!*raw[0]) + while (*raw[0] != '\n') ++*raw; + *raw[0]++ = '\0'; } static Dir *