diff options
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/actions.c b/src/actions.c index df23225..d73ad1e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2147,7 +2147,7 @@ parse_args (char *str, struct list_head *list, int nargs, int raw) int len = 0; int str_escape = 0; int in_str = 0; - int gobble = 0; + int gobble = 1; int parsed_args = 0; if (str == NULL) @@ -2162,7 +2162,7 @@ parse_args (char *str, struct list_head *list, int nargs, int raw) { struct sbuf *s = sbuf_new(0); if (!raw) - while (*i && *i == ' ') i++; + while (*i && isspace (*i)) i++; if (*i) { sbuf_concat(s, i); @@ -2172,6 +2172,13 @@ parse_args (char *str, struct list_head *list, int nargs, int raw) break; } + /* Should we eat the whitespace? */ + if (gobble) + { + while (*i && isspace (*i)) i++; + gobble = 0; + } + /* Escaped characters always get added. */ if (str_escape) { @@ -2208,7 +2215,7 @@ parse_args (char *str, struct list_head *list, int nargs, int raw) break; } } - else if (*i == ' ' && !in_str) + else if (isspace (*i) && !in_str) { /* End the current arg, and start a new one. */ struct sbuf *s = sbuf_new(0); @@ -2224,15 +2231,6 @@ parse_args (char *str, struct list_head *list, int nargs, int raw) tmp[len] = *i; len++; } - - /* Should we eat the whitespace? */ - if (gobble) - { - while (*i && *i == ' ') i++; - /* Did we go too far? */ - if (*i && *i != ' ') i--; - gobble = 0; - } } /* Add the remaining text in tmp. */ if (ret == NULL && len) |