aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-07-17 14:00:42 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-07-17 14:00:42 +0000
commit54d50a0b476ec2e6015dffd9598edc2d7968047b (patch)
tree4ee4b75067cabcbb0dca4b1c99be668dc48b563c /libbb
parent679212836a881b53382ea6bd811f38e00705d50d (diff)
downloadbusybox-54d50a0b476ec2e6015dffd9598edc2d7968047b.tar.gz
- fix "noreduce" flag of config_read (didn't work at all, at least for me).
- convert init's inittab parsing to the new config parser: function old new delta config_read 393 386 -7 static.actions 72 64 -8 .rodata 121772 121764 -8 parse_inittab 554 393 -161 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-184) Total: -184 bytes
Diffstat (limited to 'libbb')
-rw-r--r--libbb/parse_config.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/libbb/parse_config.c b/libbb/parse_config.c
index 70f933fe3..2bd2d4f53 100644
--- a/libbb/parse_config.c
+++ b/libbb/parse_config.c
@@ -59,7 +59,7 @@ void FAST_FUNC config_close(parser_t *parser)
int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mintokens, const char*delims,char comment)
{
char *line, *q;
- int ii;
+ int ii, seen;
/* do not treat subsequent delimiters as one delimiter */
bool noreduce = (ntokens < 0);
if (noreduce)
@@ -69,9 +69,6 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mint
config_free_data(parser);
while (1) {
- int n;
-
- // get fresh line
//TODO: speed up xmalloc_fgetline by internally using fgets, not fgetc
line = xmalloc_fgetline(parser->fp);
if (!line)
@@ -102,10 +99,10 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mint
ii = q - line;
}
// skip leading delimiters
- n = strspn(line, delims);
- if (n) {
- ii -= n;
- strcpy(line, line + n);
+ seen = strspn(line, delims);
+ if (seen) {
+ ii -= seen;
+ strcpy(line, line + seen);
}
if (ii)
break;
@@ -121,9 +118,8 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mint
parser->line = line = xrealloc(line, ii + 1);
parser->data = xstrdup(line);
- // now split line to tokens
-//TODO: discard consecutive delimiters?
- ii = 0;
+ /* now split line to tokens */
+ ii = noreduce ? seen : 0;
ntokens--; // now it's max allowed token no
while (1) {
// get next token