aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
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 da7482c6d..eaf69d97f 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
161#undef config_read 161#undef config_read
162int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims) 162int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims)
163{ 163{
164 char *line; 164 char *line, *p;
165 int ntokens, mintokens; 165 int ntokens, mintokens;
166 int t; 166 int t;
167 char alt_comment_ch;
167 168
168 if (!parser) 169 if (!parser)
169 return 0; 170 return 0;
170 171
172 alt_comment_ch = '\0';
173 if (flags & PARSE_ALT_COMMENTS)
174 alt_comment_ch = *delims++;
175
171 ntokens = (uint8_t)flags; 176 ntokens = (uint8_t)flags;
172 mintokens = (uint8_t)(flags >> 8); 177 mintokens = (uint8_t)(flags >> 8);
173 178
@@ -184,7 +189,10 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const
184 if (flags & PARSE_TRIM) 189 if (flags & PARSE_TRIM)
185 line += strspn(line, delims + 1); 190 line += strspn(line, delims + 1);
186 191
187 if (line[0] == '\0' || line[0] == delims[0]) 192 p = line;
193 if (flags & PARSE_WS_COMMENTS)
194 p = skip_whitespace(p);
195 if (p[0] == '\0' || p[0] == delims[0] || p[0] == alt_comment_ch)
188 goto again; 196 goto again;
189 197
190 if (flags & PARSE_KEEP_COPY) { 198 if (flags & PARSE_KEEP_COPY) {