From: Greg Beaver Date: Mon, 24 Dec 2007 21:40:54 +0000 (+0000) Subject: fix windows build X-Git-Tag: RELEASE_2_0_0a1~1110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e861913e398edbf225a3495746b645e207bbe426;p=php fix windows build # there HAS to be a better way to do this... --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 122a89b2f4..18c1be04f9 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1595,6 +1595,49 @@ static int php_check_dots(const char *element, int n) #define IS_BACKSLASH(c) ((c) == '/') +#ifdef PHP_WIN32 +/* stupid-ass non-extern declaration in tsrm_strtok.h breaks dumbass MS compiler */ +static inline int in_character_class(char ch, const char *delim) +{ + while (*delim) { + if (*delim == ch) { + return 1; + } + delim++; + } + return 0; +} + +char *tsrm_strtok_r(char *s, const char *delim, char **last) +{ + char *token; + + if (s == NULL) { + s = *last; + } + + while (*s && in_character_class(*s, delim)) { + s++; + } + if (!*s) { + return NULL; + } + + token = s; + + while (*s && !in_character_class(*s, delim)) { + s++; + } + if (!*s) { + *last = s; + } else { + *s = '\0'; + *last = s + 1; + } + return token; +} +#endif + /** * Remove .. and . references within a phar filename */ diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index a6f999c93c..c3b0d42776 100755 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -47,7 +47,9 @@ #include "ext/standard/sha1.h" #include "ext/standard/php_var.h" #include "ext/standard/php_smart_str.h" +#ifndef PHP_WIN32 #include "TSRM/tsrm_strtok_r.h" +#endif #if HAVE_SPL #include "ext/spl/spl_array.h" #include "ext/spl/spl_directory.h" @@ -255,6 +257,9 @@ union _phar_entry_object { #endif BEGIN_EXTERN_C() +#ifdef PHP_WIN32 +char *tsrm_strtok_r(char *s, const char *delim, char **last); +#endif void phar_request_initialize(TSRMLS_D);