summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-05 11:21:10 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-05 11:21:10 -0800
commit2cf9bde38908a45ec35fd0d6f6f10ebde00c69f1 (patch)
tree9e544ec8e5965627982c943f5ea5206f4283a247
parent31cbc49a79554da90e1cab0e85b1fb62afcc0c36 (diff)
downloadmake-2cf9bde38908a45ec35fd0d6f6f10ebde00c69f1.tar.gz
make-2cf9bde38908a45ec35fd0d6f6f10ebde00c69f1.tar.bz2
make-2cf9bde38908a45ec35fd0d6f6f10ebde00c69f1.zip
fix whitespace tokenization
-rw-r--r--function.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/function.c b/function.c
index e2f6c8c..680e954 100644
--- a/function.c
+++ b/function.c
@@ -1133,19 +1133,14 @@ func_sort (char *o, char **argv, const char *funcname UNUSED)
/* Find the maximum number of words we'll have. */
t = argv[0];
- wordi = 1;
- while (*t != '\0')
+ wordi = 0;
+ while ((p = find_next_token (&t, &len)) != 0)
{
- char c = *(t++);
-
- if (! isspace ((unsigned char)c))
- continue;
-
- ++wordi;
-
- while (isspace ((unsigned char)*t))
- ++t;
+ ++t;
+ wordi++;
}
+ if (! wordi)
+ wordi = 1;
words = xmalloc (wordi * sizeof (char *));