27 |
|
char buf[MAXFLEN]; |
28 |
|
register int n; |
29 |
|
/* load file into buffer */ |
30 |
+ |
if (fname == NULL) |
31 |
+ |
return(-1); /* no filename */ |
32 |
|
if ((fd = open(fname, 0)) < 0) |
33 |
|
return(-1); /* open error */ |
34 |
|
n = read(fd, buf, MAXFLEN); |
57 |
|
if (cp == NULL) /* ENOMEM */ |
58 |
|
return(-1); |
59 |
|
strcpy(cp, str); |
60 |
< |
for (ap = avl; *cp; *cp++ = '\0') { |
61 |
< |
while (isspace(*cp)) /* skip leading space */ |
62 |
< |
cp++; |
63 |
< |
if (*cp) { /* add argument to list */ |
64 |
< |
*ap++ = cp; |
65 |
< |
while (*cp && !isspace(*cp)) |
66 |
< |
cp++; |
67 |
< |
} |
60 |
> |
ap = avl; /* parse into words */ |
61 |
> |
for ( ; ; ) { |
62 |
> |
while (isspace(*cp)) /* nullify spaces */ |
63 |
> |
*cp++ = '\0'; |
64 |
> |
if (!*cp) /* all done? */ |
65 |
> |
break; |
66 |
> |
*ap++ = cp; /* add argument to list */ |
67 |
> |
while (*++cp && !isspace(*cp)) |
68 |
> |
; |
69 |
|
} |
70 |
|
*ap = NULL; |
71 |
|
return(ap - avl); |