X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Flibpspp%2Fstring-array.c;h=a22ade6e10880e28fb47bbca5010ec63a3fa7737;hb=6c8b13da57b074620495a0543bd7944bca574a42;hp=b9067ab60d431f260dad52a04ca05aaf0822b7d7;hpb=f550aee00a62fe1d8baf62d83cd7efef6cc2ee92;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.