From af3af25d3e1cc0821edd2b660ba92c792cb1e988 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 4 Jan 2010 20:42:55 +0000 Subject: [PATCH] Fix whitespace parsing in config file --- ChangeLog | 3 +++ src/config_file.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6433a4c..53246b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ * src/config_file.c (config_file_name): Support parsing the additional config file. + * src/config_file.c (next_token): Fix parsing config files where + there is no whitespace between tokens. + 2010-01-03 Nick Gasson * src/xcowsay.c (main): Add --at option to specify cow location diff --git a/src/config_file.c b/src/config_file.c index 3e9cd7b..3d071b3 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -87,17 +87,19 @@ static token_t next_token(FILE *f, strbuf_t* sbuf, int *lineno, jmp_buf *escape) } } else if (!skip_to_eol) { - if (isspace(next)) { - if (has_chars(sbuf)) - return tTOKEN; + if (isalpha(next) || isdigit(next) || '_' == next + || '/' == next || '.' == next || '-' == next) + push_char(sbuf, next); + else if (has_chars(sbuf)) { + ungetc(next, f); + return tTOKEN; } + else if (isspace(next)) + ; // Skip else if ('=' == next) return tEQUALS; else if ('#' == next) skip_to_eol = true; - else if (isalpha(next) || isdigit(next) || '_' == next - || '/' == next || '.' == next || '-' == next) - push_char(sbuf, next); else { fprintf(stderr, "Illegal character in xcowsayrc: %c\n", next); longjmp(*escape, 3); -- 2.39.2