diff options
author | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-03-30 15:07:59 +0000 |
---|---|---|
committer | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-03-30 15:07:59 +0000 |
commit | b463207e4730edf3877b57577e8ac91decaca5c8 (patch) | |
tree | 09035901b6c2404ff0e67c64c9abacd000c9ec68 /src/common | |
parent | 8a5388a4807da16705f6a9fcd39b7d50e2716ce7 (diff) | |
download | hercules-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')
-rw-r--r-- | src/common/strlib.c | 42 | ||||
-rw-r--r-- | src/common/strlib.h | 4 |
2 files changed, 17 insertions, 29 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
diff --git a/src/common/strlib.h b/src/common/strlib.h index 038eea1c6..7eb167057 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -12,8 +12,8 @@ char* jstrescapecpy (char* pt,char* spt); int jmemescapecpy (char* pt,char* spt, int size);
#if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
-#define strtok_r(s,delim,save_ptr) athena_strtok_r(s,delim,save_ptr)
-char *athena_strtok_r (char *s, const char *delim, char **save_ptr);
+#define strtok_r(s,delim,save_ptr) athena_strtok_r((s),(delim),(save_ptr))
+char *athena_strtok_r(char *s1, const char *s2, char **lasts);
#endif
// custom functions
|