diff --git a/libifupdown/config-parser.c b/libifupdown/config-parser.c index 0e16b70..f533cfb 100644 --- a/libifupdown/config-parser.c +++ b/libifupdown/config-parser.c @@ -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++; diff --git a/libifupdown/tokenize.h b/libifupdown/tokenize.h index fc7e61f..f0aed3d 100644 --- a/libifupdown/tokenize.h +++ b/libifupdown/tokenize.h @@ -19,7 +19,7 @@ #include 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