{
char *tmp;
+ skip_whitespace(ctx, str);
tmp = next_arg(ctx, str, false, false);
if (*tmp && (ctx->flags & UCI_FLAG_STRICT))
uci_parse_error(ctx, *str, "too many arguments");
static void uci_parse_line(struct uci_context *ctx, bool single)
{
struct uci_parse_context *pctx = ctx->pctx;
- char *word, *brk = NULL;
-
- for (word = strtok_r(pctx->buf, ";", &brk);
- word;
- word = strtok_r(NULL, ";", &brk)) {
-
- char *pbrk = NULL;
- word = strtok_r(word, " \t", &pbrk);
+ char *word, *brk;
+ word = pctx->buf;
+ do {
+ brk = NULL;
+ word = strtok_r(word, " \t", &brk);
if (!word)
- continue;
+ return;
switch(word[0]) {
+ case 0:
case '#':
return;
case 'p':
uci_parse_error(ctx, word, "unterminated command");
break;
}
- }
+ } while (1);
}
/* max number of characters that escaping adds to the string */
*/
static void parse_str(struct uci_context *ctx, char **str, char **target)
{
+ bool next = true;
do {
switch(**str) {
case '\'':
/* fall through */
case 0:
goto done;
+ case ';':
+ next = false;
+ goto done;
case '\\':
if (!parse_backslash(ctx, str))
continue;
* character, skip to the next one, because the whitespace will
* be overwritten by a null byte here
*/
- if (**str)
+ if (**str && next)
*str += 1;
/* terminate the parsed string */
val = ptr = *str;
skip_whitespace(ctx, str);
- parse_str(ctx, str, &ptr);
+ if(*str[0] == ';') {
+ *str[0] = 0;
+ *str += 1;
+ } else {
+ parse_str(ctx, str, &ptr);
+ }
if (!*val) {
if (required)
uci_parse_error(ctx, *str, "insufficient arguments");