summaryrefslogtreecommitdiff
path: root/common/strtok_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/strtok_r.c')
-rw-r--r--common/strtok_r.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/common/strtok_r.c b/common/strtok_r.c
new file mode 100644
index 0000000..a0b0997
--- /dev/null
+++ b/common/strtok_r.c
@@ -0,0 +1,35 @@
+/*
+ * public domain strtok_r()
+ */
+
+#include <string.h>
+
+char* strtok_r( char* str, const char* delim, char** nextp )
+{
+ char* ret;
+
+ if( str == NULL )
+ {
+ str = *nextp;
+ }
+
+ str += strspn( str, delim );
+
+ if( *str == '\0' )
+ {
+ return NULL;
+ }
+
+ ret = str;
+
+ str += strcspn( str, delim );
+
+ if( *str )
+ {
+ *str++ = '\0';
+ }
+
+ *nextp = str;
+
+ return ret;
+}