diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2004-12-20 07:38:33 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:19:09 -0700 |
commit | 9f8dfa19cfd2b502bf794f39a421cbb7c4cc0404 (patch) | |
tree | b91b9ebebd7a08a722d60495af2a2b594dd50d0e /namedev_parse.c | |
parent | a07dc29e602440541ce531e03737bc1f926a0ef3 (diff) |
[PATCH] allow multiline rules by backslash at the end of the line
On Sun, 2004-12-19 at 18:31 +0100, Marco d'Itri wrote:
> > On Dec 19, Kay Sievers <kay.sievers@vrfy.org> wrote:
>
> > (Feature request: would it be possible to extend the rules files parser
> > to support continuation lines? I'd like it to consider lines starting
> > with white space as part of the previous line.)
>
> How about the usual backslash at the end of the line. Here is a simple
> patch.
Diffstat (limited to 'namedev_parse.c')
-rw-r--r-- | namedev_parse.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/namedev_parse.c b/namedev_parse.c index 7190cdd1a8..3b14a6a500 100644 --- a/namedev_parse.c +++ b/namedev_parse.c @@ -126,14 +126,15 @@ static int namedev_parse(const char *filename, void *data) cur = 0; lineno = 0; while (cur < bufsize) { + int i, j; + count = buf_get_line(buf, bufsize, cur); bufline = &buf[cur]; cur += count+1; lineno++; if (count >= LINE_SIZE) { - info("line too long, rule skipped %s, line %d", - filename, lineno); + info("line too long, rule skipped %s, line %d", filename, lineno); continue; } @@ -149,8 +150,14 @@ static int namedev_parse(const char *filename, void *data) if (bufline[0] == COMMENT_CHARACTER) continue; - strncpy(line, bufline, count); - line[count] = '\0'; + /* skip backslash and newline from multi line rules */ + for (i = j = 0; i < count; i++) { + if (bufline[i] == '\\' || bufline[i] == '\n') + continue; + + line[j++] = bufline[i]; + } + line[j] = '\0'; dbg_parse("read '%s'", line); /* get all known keys */ |