20 |
|
|
21 |
|
|
22 |
|
char * |
23 |
< |
atos(rs, nb, s) /* get next word from string */ |
23 |
> |
atos(rs, nb, s) /* get word from string, returning rs */ |
24 |
|
char *rs; |
25 |
|
register int nb; |
26 |
|
register char *s; |
33 |
|
*cp++ = *s++; |
34 |
|
*cp = '\0'; |
35 |
|
return(rs); |
36 |
+ |
} |
37 |
+ |
|
38 |
+ |
|
39 |
+ |
char * |
40 |
+ |
nextword(cp, nb, s) /* get (quoted) word, returning new s */ |
41 |
+ |
register char *cp; |
42 |
+ |
register int nb; |
43 |
+ |
register char *s; |
44 |
+ |
{ |
45 |
+ |
int quote = 0; |
46 |
+ |
|
47 |
+ |
if (s == NULL) return(NULL); |
48 |
+ |
while (isspace(*s)) |
49 |
+ |
s++; |
50 |
+ |
switch (*s) { |
51 |
+ |
case '\0': |
52 |
+ |
return(NULL); |
53 |
+ |
case '"': |
54 |
+ |
case '\'': |
55 |
+ |
quote = *s++; |
56 |
+ |
} |
57 |
+ |
while (--nb > 0 && *s && (quote ? *s!=quote : !isspace(*s))) |
58 |
+ |
*cp++ = *s++; |
59 |
+ |
*cp = '\0'; |
60 |
+ |
if (quote && *s==quote) |
61 |
+ |
s++; |
62 |
+ |
return(s); |
63 |
|
} |
64 |
|
|
65 |
|
|