]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #21597 (made glob() understand Windows paths).
authorEdin Kadribasic <edink@php.net>
Mon, 27 Jan 2003 16:32:48 +0000 (16:32 +0000)
committerEdin Kadribasic <edink@php.net>
Mon, 27 Jan 2003 16:32:48 +0000 (16:32 +0000)
NEWS
ext/standard/dir.c
win32/glob.c

diff --git a/NEWS b/NEWS
index f4231f83cf3671f231e9e0f945f6882f0f03cf4b..a56bd393b21d155dd93c35faef68664995a4eb9d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PHP 4                                                                      NEWS
   . Disallow linkage of Berkeley db submodules against libraries with
     different major version.
   . Disallow configuring of more than one Berkeley db handler. 
+- Fixed bug #21597 (made glob() understand Windows paths). (Edin)
 - Fixed bug #20857 (snmpset() failed always, patch by: rs@epost.de). (Jani)
 - Fixed bug #14532 (fixed connection_status() to return 2 for timeouts). (Jani)
 - Fixed bug #21525 (bind_textdomain_codeset() now available on Windows). (Edin)
index d44528bb6cc68d6df71ee5eb38b445014a249e78..449e4e78a61b2015d999c03a9676983ee8ea5d29 100644 (file)
@@ -378,7 +378,7 @@ PHP_FUNCTION(glob)
                        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 4ffe06ae4f5679ddeff43e87cb541989e8ba0078..f9011536adce9bb7eb059a92c2a06a9fbbe2bc90 100644 (file)
@@ -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 @@ glob(pattern, flags, errfunc, pglob)
        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 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
                                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 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
                /* 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 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
                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++;