diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-01-11 00:37:17 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-01-11 00:37:17 +0100 |
commit | 499597d6efb0de5bb6d6f52bda1f348478d7f5a9 (patch) | |
tree | 002da32a858f8c89cbacfe15f9d812c202810403 | |
parent | 982fdaf4b2f335506e570a06d5eab09068da3f61 (diff) | |
download | busybox-w32-499597d6efb0de5bb6d6f52bda1f348478d7f5a9.tar.gz busybox-w32-499597d6efb0de5bb6d6f52bda1f348478d7f5a9.tar.bz2 busybox-w32-499597d6efb0de5bb6d6f52bda1f348478d7f5a9.zip |
mdev: do not treat non-leading '#' chars as start of comment. Closes 4676
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 5 | ||||
-rw-r--r-- | libbb/parse_config.c | 2 | ||||
-rw-r--r-- | util-linux/mdev.c | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/include/libbb.h b/include/libbb.h index 0c266dc53..4975b97fe 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1195,13 +1195,14 @@ enum { | |||
1195 | PARSE_MIN_DIE = 0x00100000, // die if < min tokens found | 1195 | PARSE_MIN_DIE = 0x00100000, // die if < min tokens found |
1196 | // keep a copy of current line | 1196 | // keep a copy of current line |
1197 | PARSE_KEEP_COPY = 0x00200000 * ENABLE_FEATURE_CROND_D, | 1197 | PARSE_KEEP_COPY = 0x00200000 * ENABLE_FEATURE_CROND_D, |
1198 | // PARSE_ESCAPE = 0x00400000, // process escape sequences in tokens | 1198 | PARSE_EOL_COMMENTS = 0x00400000, // comments are recognized even if they aren't the first char |
1199 | // NORMAL is: | 1199 | // NORMAL is: |
1200 | // * remove leading and trailing delimiters and collapse | 1200 | // * remove leading and trailing delimiters and collapse |
1201 | // multiple delimiters into one | 1201 | // multiple delimiters into one |
1202 | // * warn and continue if less than mintokens delimiters found | 1202 | // * warn and continue if less than mintokens delimiters found |
1203 | // * grab everything into last token | 1203 | // * grab everything into last token |
1204 | PARSE_NORMAL = PARSE_COLLAPSE | PARSE_TRIM | PARSE_GREEDY, | 1204 | // * comments are recognized even if they aren't the first char |
1205 | PARSE_NORMAL = PARSE_COLLAPSE | PARSE_TRIM | PARSE_GREEDY | PARSE_EOL_COMMENTS, | ||
1205 | }; | 1206 | }; |
1206 | typedef struct parser_t { | 1207 | typedef struct parser_t { |
1207 | FILE *fp; | 1208 | FILE *fp; |
diff --git a/libbb/parse_config.c b/libbb/parse_config.c index cf5ba4deb..1590d9a4c 100644 --- a/libbb/parse_config.c +++ b/libbb/parse_config.c | |||
@@ -204,7 +204,7 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const | |||
204 | line += strcspn(line, delims[0] ? delims : delims + 1); | 204 | line += strcspn(line, delims[0] ? delims : delims + 1); |
205 | } else { | 205 | } else { |
206 | /* Combining, find comment char if any */ | 206 | /* Combining, find comment char if any */ |
207 | line = strchrnul(line, delims[0]); | 207 | line = strchrnul(line, PARSE_EOL_COMMENTS ? delims[0] : '\0'); |
208 | 208 | ||
209 | /* Trim any extra delimiters from the end */ | 209 | /* Trim any extra delimiters from the end */ |
210 | if (flags & PARSE_TRIM) { | 210 | if (flags & PARSE_TRIM) { |
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index c6be1b872..e5f0c2deb 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
@@ -206,7 +206,8 @@ static void parse_next_rule(void) | |||
206 | char *tokens[4]; | 206 | char *tokens[4]; |
207 | char *val; | 207 | char *val; |
208 | 208 | ||
209 | if (!config_read(G.parser, tokens, 4, 3, "# \t", PARSE_NORMAL)) | 209 | /* No PARSE_EOL_COMMENTS, because command may contain '#' chars */ |
210 | if (!config_read(G.parser, tokens, 4, 3, "# \t", PARSE_NORMAL & ~PARSE_EOL_COMMENTS)) | ||
210 | break; | 211 | break; |
211 | 212 | ||
212 | /* Fields: [-]regex uid:gid mode [alias] [cmd] */ | 213 | /* Fields: [-]regex uid:gid mode [alias] [cmd] */ |