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

index d31089cd1a8580c775cd515b18cfd8ae03d9e800..778c5047171c91f4251406fee8b1689b6cf8c4ef 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++;