19 |
|
|
20 |
#include "argcv.h" |
#include "argcv.h" |
21 |
|
|
|
char srtime[] = __TIME__; |
|
|
|
|
22 |
/* |
/* |
23 |
* takes a string and splits it into several strings, breaking at ' ' |
* takes a string and splits it into several strings, breaking at ' ' |
24 |
* command is the string to split |
* command is the string to split |
41 |
i = *save; |
i = *save; |
42 |
|
|
43 |
if (i >= len) |
if (i >= len) |
44 |
return i; |
return i + 1; |
45 |
|
|
46 |
/* Skip initial whitespace */ |
/* Skip initial whitespace */ |
47 |
while (i < len && isws (command[i])) |
while (i < len && isws (command[i])) |
100 |
*argv = NULL; |
*argv = NULL; |
101 |
|
|
102 |
/* Count number of arguments */ |
/* Count number of arguments */ |
103 |
*argc = 1; |
*argc = 0; |
104 |
save = 0; |
save = 0; |
105 |
|
|
106 |
while (argcv_scan (len, command, delim, cmnt, &start, &end, &save) < len) |
while (argcv_scan (len, command, delim, cmnt, &start, &end, &save) <= len) |
107 |
(*argc)++; |
(*argc)++; |
108 |
|
|
109 |
*argv = calloc ((*argc + 1), sizeof (char *)); |
*argv = calloc ((*argc + 1), sizeof (char *)); |
196 |
} |
} |
197 |
|
|
198 |
#if 0 |
#if 0 |
199 |
char *command = "set prompt=\"& \""; |
char *command = "set prompt=\"& \" "; |
200 |
|
|
201 |
main() |
main(int xargc, char **xargv) |
202 |
{ |
{ |
203 |
int i, argc; |
int i, argc; |
204 |
char **argv; |
char **argv; |
205 |
|
|
206 |
argcv_get (command, "=", NULL, &argc, &argv); |
argcv_get (xargv[1] ? xargv[1]:command, "=", "#", &argc, &argv); |
207 |
printf ("%d args:\n", argc); |
printf ("%d args:\n", argc); |
208 |
for (i = 0; i < argc; i++) |
for (i = 0; i < argc; i++) |
209 |
printf ("%s\n", argv[i]); |
printf ("%s\n", argv[i]); |