tokenizer: split out equals-as-delimiter tokenizer to its own function
This commit is contained in:
parent
4b30dc4573
commit
27a383cfa7
2 changed files with 21 additions and 3 deletions
|
@ -40,8 +40,8 @@ lif_config_parse_file(FILE *fd, const char *filename, struct lif_config_handler
|
|||
while (lif_fgetline(linebuf, sizeof linebuf, fd))
|
||||
{
|
||||
char *bufp = linebuf;
|
||||
char *key = lif_next_token(&bufp);
|
||||
char *value = lif_next_token(&bufp);
|
||||
char *key = lif_next_token_eq(&bufp);
|
||||
char *value = lif_next_token_eq(&bufp);
|
||||
|
||||
lineno++;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <ctype.h>
|
||||
|
||||
static inline char *
|
||||
lif_next_token(char **buf)
|
||||
lif_next_token_eq(char **buf)
|
||||
{
|
||||
char *out = *buf;
|
||||
|
||||
|
@ -36,4 +36,22 @@ lif_next_token(char **buf)
|
|||
return out;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
lif_next_token(char **buf)
|
||||
{
|
||||
char *out = *buf;
|
||||
|
||||
while (*out && isspace(*out))
|
||||
out++;
|
||||
|
||||
char *end = out;
|
||||
while (*end && !isspace(*end))
|
||||
end++;
|
||||
|
||||
*end++ = '\0';
|
||||
*buf = end;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue