X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Flibpspp%2Fstring-array.c;fp=src%2Flibpspp%2Fstring-array.c;h=a22ade6e10880e28fb47bbca5010ec63a3fa7737;hb=f967d0e36a2193c1249799f463ea9109b753f7a8;hp=b9067ab60d431f260dad52a04ca05aaf0822b7d7;hpb=bde4a7daf82beb5639a02079a9e682c8d33720e0;p=pspp diff --git a/src/libpspp/string-array.c b/src/libpspp/string-array.c index b9067ab60d..a22ade6e10 100644 --- a/src/libpspp/string-array.c +++ b/src/libpspp/string-array.c @@ -234,6 +234,17 @@ string_array_sort (struct string_array *sa) qsort (sa->strings, sa->n, sizeof *sa->strings, compare_strings); } +/* Divides STRING into tokens at DELIMITERS and adds each token to SA. */ +void +string_array_parse (struct string_array *sa, struct substring string, + struct substring delimiters) +{ + size_t save_idx = 0; + struct substring token; + while (ss_tokenize (string, delimiters, &save_idx, &token)) + string_array_append_nocopy (sa, ss_xstrdup (token)); +} + /* Returns a single string that consists of each of the strings in SA concatenated, separated from each other with SEPARATOR.