From 7c99000c207c120d4094277b6ede56a36b929b46 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Wed, 1 Apr 2020 18:40:02 +0200 Subject: util: improve/cleanup parseline() - remove a check that has no use/can never happen. - remove the return value as it's unused and the input size is known. - fix an old comment that doesn't reflect what the function does anymore. --- util.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 51f7bd8..24f38b5 100644 --- a/util.c +++ b/util.c @@ -171,13 +171,10 @@ absuri(char *buf, size_t bufsiz, const char *link, const char *base) return encodeuri(buf, bufsiz, tmp); } -/* Read a field-separated line from 'fp', - * separated by a character 'separator', - * 'fields' is a list of pointers with a size of FieldLast (must be >0). - * 'line' buffer is allocated using malloc, 'size' will contain the allocated - * buffer size. - * returns: amount of fields read (>0) or -1 on error. */ -size_t +/* Splits fields in the line buffer by replacing TAB separators with NUL ('\0') + * terminators and assign these fields as pointers. If there are less fields + * than expected then the field is an empty string constant. */ +void parseline(char *line, char *fields[FieldLast]) { char *prev, *s; @@ -194,8 +191,6 @@ parseline(char *line, char *fields[FieldLast]) /* make non-parsed fields empty. */ for (; i < FieldLast; i++) fields[i] = ""; - - return i; } /* Parse time to time_t, assumes time_t is signed, ignores fractions. */ -- cgit v1.2.3