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).
This commit is contained in:
parent
b131f45cbb
commit
e666e4a35b
15
src/filter.c
15
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')
|
||||
|
Loading…
Reference in New Issue
Block a user