summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2017-08-05 18:20:34 +0200
committerDenys Vlasenko2017-08-05 18:20:34 +0200
commit50db1f29bf96c2ae4dbb96763793a9592d99cf02 (patch)
tree9f99e1eab5aa1fb22d8656ab42a2d048bc7fcc2c /libbb
parent20077c1429915b2c223e4d179a033f2b1806872c (diff)
downloadbusybox-50db1f29bf96c2ae4dbb96763793a9592d99cf02.zip
busybox-50db1f29bf96c2ae4dbb96763793a9592d99cf02.tar.gz
sysctl: recognize ";comment" and "<whitespace>#comment" lines
function old new delta config_read 639 699 +60 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/parse_config.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libbb/parse_config.c b/libbb/parse_config.c
index da7482c..eaf69d9 100644
--- a/libbb/parse_config.c
+++ b/libbb/parse_config.c
@@ -161,13 +161,18 @@ mintokens > 0 make config_read() print error message if less than mintokens
#undef config_read
int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims)
{
- char *line;
+ char *line, *p;
int ntokens, mintokens;
int t;
+ char alt_comment_ch;
if (!parser)
return 0;
+ alt_comment_ch = '\0';
+ if (flags & PARSE_ALT_COMMENTS)
+ alt_comment_ch = *delims++;
+
ntokens = (uint8_t)flags;
mintokens = (uint8_t)(flags >> 8);
@@ -184,7 +189,10 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const
if (flags & PARSE_TRIM)
line += strspn(line, delims + 1);
- if (line[0] == '\0' || line[0] == delims[0])
+ p = line;
+ if (flags & PARSE_WS_COMMENTS)
+ p = skip_whitespace(p);
+ if (p[0] == '\0' || p[0] == delims[0] || p[0] == alt_comment_ch)
goto again;
if (flags & PARSE_KEEP_COPY) {