summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2020-04-01 18:40:02 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2020-04-01 18:49:24 +0200
commit7c99000c207c120d4094277b6ede56a36b929b46 (patch)
tree7fc5304ca7ec4f437c1c21f6e7b640cf83b601f0 /util.c
parent785a50c37c11c8e92387f8409d91bd77c41297b2 (diff)
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.
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
1 files changed, 4 insertions, 9 deletions
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. */