fix whitespace tokenization
authorAnas Nashif <anas.nashif@intel.com>
Mon, 5 Nov 2012 19:21:10 +0000 (11:21 -0800)
committerAnas Nashif <anas.nashif@intel.com>
Mon, 5 Nov 2012 19:21:10 +0000 (11:21 -0800)
function.c

index e2f6c8c..680e954 100644 (file)
@@ -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 *));