2 #include "string-list.h"
4 void write_list(const struct string_list
*list
)
7 for (i
= 0; i
< list
->nr
; i
++)
8 printf("[%d]: \"%s\"\n", i
, list
->items
[i
].string
);
11 int main(int argc
, char **argv
)
13 if (argc
== 5 && !strcmp(argv
[1], "split")) {
14 struct string_list list
= STRING_LIST_INIT_DUP
;
16 const char *s
= argv
[2];
18 int maxsplit
= atoi(argv
[4]);
20 i
= string_list_split(&list
, s
, delim
, maxsplit
);
23 string_list_clear(&list
, 0);
27 if (argc
== 5 && !strcmp(argv
[1], "split_in_place")) {
28 struct string_list list
= STRING_LIST_INIT_NODUP
;
30 char *s
= xstrdup(argv
[2]);
32 int maxsplit
= atoi(argv
[4]);
34 i
= string_list_split_in_place(&list
, s
, delim
, maxsplit
);
37 string_list_clear(&list
, 0);
42 fprintf(stderr
, "%s: unknown function name: %s\n", argv
[0],
43 argv
[1] ? argv
[1] : "(there was none)");