X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fsvec.c;h=bc3df23d511cb690f2b1d363b4fa859f3cb74b4c;hb=87036dbdea0cbebdd0869aefb9181817463350f0;hp=81a36b57ae7544c9ef9d7fa5b1166790d961601a;hpb=8ecd53084ce42e2e868a9c24c57b2d9a7e59cfc2;p=openvswitch diff --git a/lib/svec.c b/lib/svec.c index 81a36b57..bc3df23d 100644 --- a/lib/svec.c +++ b/lib/svec.c @@ -372,6 +372,22 @@ svec_join(const struct svec *svec, return ds_cstr(&ds); } +/* Breaks 's' into tokens at any character in 'delimiters', and appends each + * token to 'svec'. Empty tokens are not added. */ +void +svec_split(struct svec *svec, const char *s_, const char *delimiters) +{ + char *s = xstrdup(s_); + char *save_ptr = NULL; + char *token; + + for (token = strtok_r(s, delimiters, &save_ptr); token != NULL; + token = strtok_r(NULL, delimiters, &save_ptr)) { + svec_add(svec, token); + } + free(s); +} + const char * svec_back(const struct svec *svec) {