edink           Mon Jan 27 11:29:47 2003 EDT

  Modified files:              
    /php4/ext/standard  dir.c 
    /php4/win32 glob.c 
  Log:
  Fixed bug #21597 (made glob() understand windows paths)
  
  
Index: php4/ext/standard/dir.c
diff -u php4/ext/standard/dir.c:1.113 php4/ext/standard/dir.c:1.114
--- php4/ext/standard/dir.c:1.113       Tue Dec 31 11:07:35 2002
+++ php4/ext/standard/dir.c     Mon Jan 27 11:29:47 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dir.c,v 1.113 2002/12/31 16:07:35 sebastian Exp $ */
+/* $Id: dir.c,v 1.114 2003/01/27 16:29:47 edink Exp $ */
 
 /* {{{ includes/startup/misc */
 
@@ -378,7 +378,7 @@
                        cwd[0] = '\0';
                }
                cwd_skip = strlen(cwd)+1;
-               snprintf(work_pattern, MAXPATHLEN, "%s/%s", cwd, pattern);
+               snprintf(work_pattern, MAXPATHLEN, "%s%c%s", cwd, DEFAULT_SLASH, 
+pattern);
                pattern = work_pattern;
        } 
 #endif
Index: php4/win32/glob.c
diff -u php4/win32/glob.c:1.3 php4/win32/glob.c:1.4
--- php4/win32/glob.c:1.3       Tue Jun  4 17:26:06 2002
+++ php4/win32/glob.c   Mon Jan 27 11:29:47 2003
@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  */
 
-/* $Id: glob.c,v 1.3 2002/06/04 21:26:06 edink Exp $ */
+/* $Id: glob.c,v 1.4 2003/01/27 16:29:47 edink Exp $ */
 
 /*
  * glob(3) -- a superset of the one defined in POSIX 1003.2.
@@ -99,7 +99,7 @@
 #define        QUOTE           '\\'
 #define        RANGE           '-'
 #define        RBRACKET        ']'
-#define        SEP             '/'
+#define        SEP             DEFAULT_SLASH
 #define        STAR            '*'
 #define        TILDE           '~'
 #define        UNDERSCORE      '_'
@@ -171,6 +171,13 @@
        int c;
        Char *bufnext, *bufend, patbuf[MAXPATHLEN];
 
+#ifdef PHP_WIN32
+       /* Force skipping escape sequences on windows
+        * due to the ambiguity with path backslashes
+        */
+       flags |= GLOB_NOESCAPE;
+#endif
+
        patnext = (u_char *) pattern;
        if (!(flags & GLOB_APPEND)) {
                pglob->gl_pathc = 0;
@@ -558,7 +565,7 @@
                                return(0);
 
                        if (((pglob->gl_flags & GLOB_MARK) &&
-                           pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) ||
+                           !IS_SLASH(pathend[-1])) && (S_ISDIR(sb.st_mode) ||
                            (S_ISLNK(sb.st_mode) &&
                            (g_stat(pathbuf, &sb, pglob) == 0) &&
                            S_ISDIR(sb.st_mode)))) {
@@ -574,7 +581,7 @@
                /* Find end of next segment, copy tentatively to pathend. */
                q = pathend;
                p = pattern;
-               while (*p != EOS && *p != SEP) {
+               while (*p != EOS && !IS_SLASH(*p)) {
                        if (ismeta(*p))
                                anymeta = 1;
                        if (q+1 > pathend_last)
@@ -585,7 +592,7 @@
                if (!anymeta) {         /* No expansion, do next segment. */
                        pathend = q;
                        pattern = p;
-                       while (*pattern == SEP) {
+                       while (IS_SLASH(*pattern)) {
                                if (pathend+1 > pathend_last)
                                        return (1);
                                *pathend++ = *pattern++;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to