diff options
author | Janosch Hoffmann <janosch.hoffmann@hotmail.de> | 2019-05-05 20:13:38 +0200 |
---|---|---|
committer | rofl0r <rofl0r@users.noreply.github.com> | 2019-05-05 19:13:38 +0100 |
commit | e666e4a35b07a406437e4c58a15d81adf7cb5fd7 (patch) | |
tree | 5246c480cc6558aa6f6550b7e97c31a70c3bad2e | |
parent | b131f45cbb4b829d7e520392a2dcfc9b41044351 (diff) |
filter file: Don't ignore lines with leading whitespace (#239)
The new code skips leading whitespaces before removing trailing
whitespaces and comments.
Without doing this, lines with leading whitespace are treated like empty
lines (i.e. they are ignored).
-rw-r--r-- | src/filter.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/filter.c b/src/filter.c index 3164191..e18132e 100644 --- a/src/filter.c +++ b/src/filter.c @@ -52,7 +52,7 @@ void filter_init (void) FILE *fd; struct filter_list *p; char buf[FILTER_BUFFER_LEN]; - char *s; + char *s, *start; int cflags; if (fl || already_init) { @@ -73,11 +73,16 @@ void filter_init (void) cflags |= REG_ICASE; while (fgets (buf, FILTER_BUFFER_LEN, fd)) { + /* skip leading whitespace */ + s = buf; + while (*s && isspace ((unsigned char) *s)) + s++; + start = s; + /* * Remove any trailing white space and * comments. */ - s = buf; while (*s) { if (isspace ((unsigned char) *s)) break; @@ -93,11 +98,7 @@ void filter_init (void) ++s; } *s = '\0'; - - /* skip leading whitespace */ - s = buf; - while (*s && isspace ((unsigned char) *s)) - s++; + s = start; /* skip blank lines and comments */ if (*s == '\0') |