--- src/actions.c.orig Thu Mar 16 02:27:17 2006 +++ src/actions.c Thu Aug 17 15:58:08 2006 @@ -2158,7 +2158,7 @@ parse_args (char *str, struct list_head { struct sbuf *s = sbuf_new(0); if (!raw) - while (*i && *i == ' ') i++; + while (*i && isspace(*i)) i++; if (*i) { sbuf_concat(s, i); @@ -2204,7 +2204,7 @@ parse_args (char *str, struct list_head 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,9 +2224,9 @@ parse_args (char *str, struct list_head /* Should we eat the whitespace? */ if (gobble) { - while (*i && *i == ' ') i++; + while (*i && isspace(*i)) i++; /* Did we go too far? */ - if (*i && *i != ' ') i--; + if (*i && !isspace(*i)) i--; gobble = 0; } } @@ -2305,23 +2305,33 @@ command (int interactive, char *data) static int alias_recursive_depth = 0; cmdret *result = NULL; char *cmd, *rest; - char *input; user_command *uc; int i; if (data == NULL) return cmdret_new (RET_FAILURE, NULL); - /* get a writable copy for strtok() */ - input = xstrdup (data); + while (isspace(*data)) + data++; - cmd = strtok (input, " "); + /* get a writable copy for tokenizing */ + cmd = xstrdup (data); - if (cmd == NULL) + if (!*cmd) goto done; - rest = strtok (NULL, "\0"); + for (rest = cmd; *rest && !isspace(*rest); rest++) + ; + if (*rest) { + *rest++ = 0; + while (isspace(*rest)) + rest++; + } + + if (!*rest) + rest = NULL; + PRINT_DEBUG (("cmd==%s rest==%s\n", cmd, rest)); /* Look for it in the aliases, first. */ @@ -2424,7 +2434,7 @@ command (int interactive, char *data) result = cmdret_new (RET_FAILURE, MESSAGE_UNKNOWN_COMMAND, cmd); done: - free (input); + free (cmd); return result; }