Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/string.c')
-rw-r--r--source/blender/blenlib/intern/string.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index db5d4dc99eb..3ec84e0b593 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -377,6 +375,35 @@ int BLI_natstrcmp(const char *s1, const char *s2)
return 0;
}
+/* As unfortunately strtok_r is not available everywhere... */
+char *BLI_strtok_r(char *str, const char *delimiter, char **ctx)
+{
+ char *cut = NULL, *ret = NULL;
+ char *split = str ? str : *ctx;
+
+ if(!split) {
+ return ret;
+ }
+
+ cut = strchr(split, *delimiter);
+ if(cut) {
+ size_t len_ret = cut - split;
+ size_t len_ctx = strlen(split) - len_ret - 1;
+ ret = BLI_strdupn(split, len_ret);
+ if(len_ctx > 0) {
+ *ctx = split+len_ret+1;
+ }
+ else {
+ *ctx = NULL;
+ }
+ }
+ else {
+ ret = BLI_strdup(split);
+ *ctx = NULL;
+ }
+ return ret;
+}
+
void BLI_timestr(double _time, char *str)
{
/* format 00:00:00.00 (hr:min:sec) string has to be 12 long */