]> granicus.if.org Git - php/commitdiff
fix windows build
authorGreg Beaver <cellog@php.net>
Mon, 24 Dec 2007 21:40:54 +0000 (21:40 +0000)
committerGreg Beaver <cellog@php.net>
Mon, 24 Dec 2007 21:40:54 +0000 (21:40 +0000)
# there HAS to be a better way to do this...

ext/phar/phar.c
ext/phar/phar_internal.h

index 122a89b2f4c907db6bd2d65ae7420e24c8f7331c..18c1be04f94d3784da5d9b2d6052d718ea9d5cc1 100644 (file)
@@ -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
  */
index a6f999c93cee1528530faac76718e74ca1f5de05..c3b0d42776449a1d39eb243e3d5cbabf57abf593 100755 (executable)
@@ -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);