summaryrefslogtreecommitdiff
path: root/src/common/strlib.c
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-30 15:07:59 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-30 15:07:59 +0000
commitb463207e4730edf3877b57577e8ac91decaca5c8 (patch)
tree09035901b6c2404ff0e67c64c9abacd000c9ec68 /src/common/strlib.c
parent8a5388a4807da16705f6a9fcd39b7d50e2716ce7 (diff)
downloadhercules-b463207e4730edf3877b57577e8ac91decaca5c8.tar.gz
hercules-b463207e4730edf3877b57577e8ac91decaca5c8.tar.bz2
hercules-b463207e4730edf3877b57577e8ac91decaca5c8.tar.xz
hercules-b463207e4730edf3877b57577e8ac91decaca5c8.zip
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5812 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/strlib.c')
-rw-r--r--src/common/strlib.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c
index bd2b928c0..c2c2ae1ac 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -137,35 +137,23 @@ char *trim(char *str, const char *delim)
return str;
}
-#ifdef _WIN32
-char *athena_strtok_r (char *s, const char *delim, char **save_ptr)
+#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
+char *athena_strtok_r(char *s1, const char *s2, char **lasts)
{
- char *token;
+ char *ret;
- if (s == NULL)
- s = *save_ptr;
-
- /* Scan leading delimiters. */
- s += strspn (s, delim);
- if (*s == '\0')
- {
- *save_ptr = s;
+ if (s1 == NULL)
+ s1 = *lasts;
+ while(*s1 && strchr(s2, *s1))
+ ++s1;
+ if(*s1 == '\0')
return NULL;
- }
-
- /* Find the end of the token. */
- token = s;
- s = strpbrk (token, delim);
- if (s == NULL)
- /* This token finishes the string. */
- /* *save_ptr = __rawmemchr (token, '\0'); */
- *save_ptr = token + strlen (token);
- else
- {
- /* Terminate the token and make *SAVE_PTR point past it. */
- *s = '\0';
- *save_ptr = s + 1;
- }
- return token;
+ ret = s1;
+ while(*s1 && !strchr(s2, *s1))
+ ++s1;
+ if(*s1)
+ *s1++ = '\0';
+ *lasts = s1;
+ return ret;
}
#endif