summaryrefslogtreecommitdiff
path: root/libpsx/src
diff options
context:
space:
mode:
Diffstat (limited to 'libpsx/src')
-rw-r--r--libpsx/src/libc/string.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/libpsx/src/libc/string.c b/libpsx/src/libc/string.c
index 2ab2f0b..791e1df 100644
--- a/libpsx/src/libc/string.c
+++ b/libpsx/src/libc/string.c
@@ -3,7 +3,7 @@
*
* Part of the PSXSDK C library
*/
-
+#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -439,6 +439,50 @@ char *strsep(char **stringp, const char *delim)
return old;
}
+/*
+ * public domain strtok_r() by Charlie Gordon
+ *
+ * from comp.lang.c 9/14/2007
+ *
+ * http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
+ *
+ * (Declaration that it's public domain):
+ * http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
+ */
+
+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;
+}
+
char *strtok(char *str, const char *sep)
{
int x, y;