summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/actions.c22
2 files changed, 16 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 77ccbbe..59643ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-27 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/actions.c (parse_args): gobble spaces at the beginning of
+ the string.
+ (parse_args): use isspace to test for spaces
+
2006-08-23 Shawn Betts <sabetts@vcn.bc.ca>
* src/bar.c (prepare_bar): cap the width and height to the size of
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)