summaryrefslogtreecommitdiff
path: root/libavutil/avstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavutil/avstring.c')
-rw-r--r--libavutil/avstring.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 4c504482da..247cd71745 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -160,6 +160,35 @@ char *av_get_token(const char **buf, const char *term)
return ret;
}
+char *av_strtok(char *s, const char *delim, char **saveptr)
+{
+ char *tok;
+
+ if (!s && !(s = *saveptr))
+ return NULL;
+
+ /* skip leading delimiters */
+ s += strspn(s, delim);
+
+ /* s now points to the first non delimiter char, or to the end of the string */
+ if (!*s) {
+ *saveptr = NULL;
+ return NULL;
+ }
+ tok = s++;
+
+ /* skip non delimiters */
+ s += strcspn(s, delim);
+ if (*s) {
+ *s = 0;
+ *saveptr = s+1;
+ } else {
+ *saveptr = NULL;
+ }
+
+ return tok;
+}
+
#ifdef TEST
#undef printf