diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-07-17 14:00:42 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-07-17 14:00:42 +0000 |
commit | 54d50a0b476ec2e6015dffd9598edc2d7968047b (patch) | |
tree | 4ee4b75067cabcbb0dca4b1c99be668dc48b563c /libbb/parse_config.c | |
parent | 679212836a881b53382ea6bd811f38e00705d50d (diff) | |
download | busybox-w32-54d50a0b476ec2e6015dffd9598edc2d7968047b.tar.gz busybox-w32-54d50a0b476ec2e6015dffd9598edc2d7968047b.tar.bz2 busybox-w32-54d50a0b476ec2e6015dffd9598edc2d7968047b.zip |
- 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/parse_config.c')
-rw-r--r-- | libbb/parse_config.c | 18 |
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) | |||
59 | int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mintokens, const char*delims,char comment) | 59 | int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mintokens, const char*delims,char comment) |
60 | { | 60 | { |
61 | char *line, *q; | 61 | char *line, *q; |
62 | int ii; | 62 | int ii, seen; |
63 | /* do not treat subsequent delimiters as one delimiter */ | 63 | /* do not treat subsequent delimiters as one delimiter */ |
64 | bool noreduce = (ntokens < 0); | 64 | bool noreduce = (ntokens < 0); |
65 | if (noreduce) | 65 | if (noreduce) |
@@ -69,9 +69,6 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mint | |||
69 | config_free_data(parser); | 69 | config_free_data(parser); |
70 | 70 | ||
71 | while (1) { | 71 | while (1) { |
72 | int n; | ||
73 | |||
74 | // get fresh line | ||
75 | //TODO: speed up xmalloc_fgetline by internally using fgets, not fgetc | 72 | //TODO: speed up xmalloc_fgetline by internally using fgets, not fgetc |
76 | line = xmalloc_fgetline(parser->fp); | 73 | line = xmalloc_fgetline(parser->fp); |
77 | if (!line) | 74 | if (!line) |
@@ -102,10 +99,10 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mint | |||
102 | ii = q - line; | 99 | ii = q - line; |
103 | } | 100 | } |
104 | // skip leading delimiters | 101 | // skip leading delimiters |
105 | n = strspn(line, delims); | 102 | seen = strspn(line, delims); |
106 | if (n) { | 103 | if (seen) { |
107 | ii -= n; | 104 | ii -= seen; |
108 | strcpy(line, line + n); | 105 | strcpy(line, line + seen); |
109 | } | 106 | } |
110 | if (ii) | 107 | if (ii) |
111 | break; | 108 | break; |
@@ -121,9 +118,8 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mint | |||
121 | parser->line = line = xrealloc(line, ii + 1); | 118 | parser->line = line = xrealloc(line, ii + 1); |
122 | parser->data = xstrdup(line); | 119 | parser->data = xstrdup(line); |
123 | 120 | ||
124 | // now split line to tokens | 121 | /* now split line to tokens */ |
125 | //TODO: discard consecutive delimiters? | 122 | ii = noreduce ? seen : 0; |
126 | ii = 0; | ||
127 | ntokens--; // now it's max allowed token no | 123 | ntokens--; // now it's max allowed token no |
128 | while (1) { | 124 | while (1) { |
129 | // get next token | 125 | // get next token |