diff options
author | sabetts <sabetts> | 2006-08-27 07:57:55 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2006-08-27 07:57:55 +0000 |
commit | 7977c0c3508e1437f50a900d827e9259f0b962bf (patch) | |
tree | 04ea48e77624f3eded1aa922b12af7d623414dea /src | |
parent | d0c7cae25a54f6972c97c032ea4ae356933146bc (diff) | |
download | ratpoison-7977c0c3508e1437f50a900d827e9259f0b962bf.zip |
(parse_args): gobble spaces at the beginning of
the string.
(parse_args): use isspace to test for spaces
Diffstat (limited to 'src')
-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) |