55 |
|
if (cp == NULL) /* ENOMEM */ |
56 |
|
return(-1); |
57 |
|
strcpy(cp, str); |
58 |
< |
for (ap = avl; *cp; *cp++ = '\0') { |
59 |
< |
while (isspace(*cp)) /* skip leading space */ |
58 |
> |
ap = avl; /* parse into words */ |
59 |
> |
for ( ; ; ) { |
60 |
> |
while (isspace(*cp)) /* nullify spaces */ |
61 |
> |
*cp++ = '\0'; |
62 |
> |
if (!*cp) /* all done? */ |
63 |
> |
break; |
64 |
> |
*ap++ = cp; /* add argument to list */ |
65 |
> |
while (*cp && !isspace(*cp)) |
66 |
|
cp++; |
61 |
– |
if (*cp) { /* add argument to list */ |
62 |
– |
*ap++ = cp; |
63 |
– |
while (*cp && !isspace(*cp)) |
64 |
– |
cp++; |
65 |
– |
} |
67 |
|
} |
68 |
|
*ap = NULL; |
69 |
|
return(ap - avl); |