]> granicus.if.org Git - php/commitdiff
handle return value for "no matches" on systems that don't return
authorHartmut Holzgraefe <hholzgra@php.net>
Tue, 3 Jun 2003 11:01:16 +0000 (11:01 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Tue, 3 Jun 2003 11:01:16 +0000 (11:01 +0000)
GLOB_NOMATCH consistent to those that do (return array(), not FALSE)

ext/standard/dir.c

index 4396a54566ef66a02784b02742d9e96e04d7d7d1..cfa792f47713e588891d9feece5e9fe0b5f6b218 100644 (file)
@@ -400,11 +400,16 @@ PHP_FUNCTION(glob)
                RETURN_FALSE;
        }
 
+#ifndef GLOB_NOMATCH
+       // now catch the FreeBSD style of "no matches"
+       if (!globbuf.gl_pathc) {
+                       array_init(return_value);
+                       return;
+       }
+#endif
+
        /* we assume that any glob pattern will match files from one directory only
           so checking the dirname of the first match should be sufficient */
-       if (!globbuf.gl_pathv) {
-               RETURN_FALSE;
-       }
        strncpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN);
        if (PG(safe_mode) && (!php_checkuid(cwd, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
                RETURN_FALSE;