Taylor Blau <me@xxxxxxxxxxxx> writes: > Introduce a variant of the `string_list_split_in_place()` function that > takes a string of accepted delimiters. > > By contrast to its cousin `string_list_split_in_place()` which splits > the given string at every instance of the single character `delim`, the > `_multi` variant splits the given string any any character appearing in > the string `delim`. > > Like `strtok()`, the `_multi` variant skips past sequential delimiting > characters. For example: > > string_list_split_in_place(&xs, xstrdup("foo::bar::baz"), ":", -1); > > would place in `xs` the elements "foo", "bar", and "baz". strtok() also skips leading and trailing delimiters, i.e. the above will give you identical result for ":foo:bar:baz:". It would be useful to test that here in addition to the existing ones. > +for test_fn in test_split test_split_in_place_multi > +do > + $test_fn "foo:bar:baz" ":" "-1" <<-\EOF > + 3 > + [0]: "foo" > + [1]: "bar" > + [2]: "baz" > + EOF > > + $test_fn "foo:bar:baz" ":" "0" <<-\EOF > + 1 > + [0]: "foo:bar:baz" > + EOF > > + $test_fn "foo:bar:baz" ":" "1" <<-\EOF > + 2 > + [0]: "foo" > + [1]: "bar:baz" > + EOF > > + $test_fn "foo:bar:baz" ":" "2" <<-\EOF > + 3 > + [0]: "foo" > + [1]: "bar" > + [2]: "baz" > + EOF