aharvey                                  Fri, 04 Feb 2011 11:51:29 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=308020

Log:
Change the way HAVE_GLOB is dealt with in ext/zip per IRC conversation with
Pierre.

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/zip/php_zip.c
    U   php/php-src/trunk/ext/zip/php_zip.c

Modified: php/php-src/branches/PHP_5_3/ext/zip/php_zip.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/zip/php_zip.c      2011-02-04 11:24:29 UTC 
(rev 308019)
+++ php/php-src/branches/PHP_5_3/ext/zip/php_zip.c      2011-02-04 11:51:29 UTC 
(rev 308020)
@@ -473,10 +473,12 @@
 #define GLOB_FLAGMASK (~GLOB_ONLYDIR)
 #else
 #define GLOB_FLAGMASK (~0)
+#endif
 #endif /* }}} */

 int php_zip_glob(char *pattern, int pattern_len, long flags, zval 
*return_value TSRMLS_DC) /* {{{ */
 {
+#ifdef HAVE_GLOB
        char cwd[MAXPATHLEN];
        int cwd_skip = 0;
 #ifdef ZTS
@@ -563,9 +565,12 @@

        globfree(&globbuf);
        return globbuf.gl_pathc;
+#else
+       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Glob support is not 
available");
+       return 0;
+#endif  /* HAVE_GLOB */
 }
 /* }}} */
-#endif /* HAVE_GLOB */

 int php_zip_pcre(char *regexp, int regexp_len, char *path, int path_len, zval 
*return_value TSRMLS_DC) /* {{{ */
 {
@@ -665,8 +670,9 @@
        return files_cnt;
 }
 /* }}} */
-#endif

+#endif
+
 /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1)
        ZEND_ARG_INFO(0, filename)
@@ -1591,11 +1597,9 @@
        char *add_path = NULL;
        int pattern_len, add_path_len, remove_path_len, path_len = 0;
        long remove_all_path = 0;
+       long flags = 0;
        zval *options = NULL;
        int found;
-#ifdef HAVE_GLOB
-       long flags = 0;
-#endif

        if (!this) {
                RETURN_FALSE;
@@ -1604,15 +1608,10 @@
        ZIP_FROM_OBJECT(intern, this);
        /* 1 == glob, 2==pcre */
        if (type == 1) {
-#ifdef HAVE_GLOB
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|la",
                                        &pattern, &pattern_len, &flags, 
&options) == FAILURE) {
                        return;
                }
-#else
-               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Glob support is not 
available");
-               RETURN_FALSE;
-#endif
        } else {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa",
                                        &pattern, &pattern_len, &path, 
&path_len, &options) == FAILURE) {
@@ -1635,9 +1634,7 @@
        }

        if (type == 1) {
-#ifdef HAVE_GLOB
                found = php_zip_glob(pattern, pattern_len, flags, return_value 
TSRMLS_CC);
-#endif
        } else {
                found = php_zip_pcre(pattern, pattern_len, path, path_len, 
return_value TSRMLS_CC);
        }
@@ -1696,7 +1693,6 @@
 }
 /* }}} */

-#ifdef HAVE_GLOB
 /* {{{ proto bool ZipArchive::addGlob(string pattern[,int flags [, array 
options]])
 Add files matching the glob pattern. See php's glob for the pattern syntax. */
 static ZIPARCHIVE_METHOD(addGlob)
@@ -1704,7 +1700,6 @@
        php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
 }
 /* }}} */
-#endif

 /* {{{ proto bool ZipArchive::addPattern(string pattern[, string path [, array 
options]])
 Add files matching the pcre pattern. See php's pcre for the pattern syntax. */
@@ -2580,13 +2575,11 @@
        ZEND_ARG_INFO(0, dirname)
 ZEND_END_ARG_INFO()

-#ifdef HAVE_GLOB
 ZEND_BEGIN_ARG_INFO_EX(arginfo_ziparchive_addglob, 0, 0, 1)
        ZEND_ARG_INFO(0, pattern)
        ZEND_ARG_INFO(0, flags)
        ZEND_ARG_INFO(0, options)
 ZEND_END_ARG_INFO()
-#endif

 ZEND_BEGIN_ARG_INFO_EX(arginfo_ziparchive_addpattern, 0, 0, 1)
        ZEND_ARG_INFO(0, pattern)
@@ -2692,9 +2685,7 @@
        ZIPARCHIVE_ME(addEmptyDir,                      
arginfo_ziparchive_addemptydir, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(addFromString,            
arginfo_ziparchive_addfromstring, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(addFile,                          
arginfo_ziparchive_addfile, ZEND_ACC_PUBLIC)
-#ifdef HAVE_GLOB
        ZIPARCHIVE_ME(addGlob,                          
arginfo_ziparchive_addglob, ZEND_ACC_PUBLIC)
-#endif
        ZIPARCHIVE_ME(addPattern,                       
arginfo_ziparchive_addpattern, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(renameIndex,                      
arginfo_ziparchive_renameindex, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(renameName,                       
arginfo_ziparchive_renamename, ZEND_ACC_PUBLIC)

Modified: php/php-src/trunk/ext/zip/php_zip.c
===================================================================
--- php/php-src/trunk/ext/zip/php_zip.c 2011-02-04 11:24:29 UTC (rev 308019)
+++ php/php-src/trunk/ext/zip/php_zip.c 2011-02-04 11:51:29 UTC (rev 308020)
@@ -473,10 +473,12 @@
 #define GLOB_FLAGMASK (~GLOB_ONLYDIR)
 #else
 #define GLOB_FLAGMASK (~0)
+#endif
 #endif /* }}} */

 int php_zip_glob(char *pattern, int pattern_len, long flags, zval 
*return_value TSRMLS_DC) /* {{{ */
 {
+#ifdef HAVE_GLOB
        char cwd[MAXPATHLEN];
        int cwd_skip = 0;
 #ifdef ZTS
@@ -563,9 +565,12 @@

        globfree(&globbuf);
        return globbuf.gl_pathc;
+#else
+       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Glob support is not 
available");
+       return 0;
+#endif  /* HAVE_GLOB */
 }
 /* }}} */
-#endif /* HAVE_GLOB */

 int php_zip_pcre(char *regexp, int regexp_len, char *path, int path_len, zval 
*return_value TSRMLS_DC) /* {{{ */
 {
@@ -665,8 +670,9 @@
        return files_cnt;
 }
 /* }}} */
-#endif

+#endif
+
 /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1)
        ZEND_ARG_INFO(0, filename)
@@ -1596,11 +1602,9 @@
        char *add_path = NULL;
        int pattern_len, add_path_len, remove_path_len, path_len = 0;
        long remove_all_path = 0;
+       long flags = 0;
        zval *options = NULL;
        int found;
-#ifdef HAVE_GLOB
-       long flags = 0;
-#endif

        if (!this) {
                RETURN_FALSE;
@@ -1609,15 +1613,10 @@
        ZIP_FROM_OBJECT(intern, this);
        /* 1 == glob, 2==pcre */
        if (type == 1) {
-#ifdef HAVE_GLOB
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|la",
                                        &pattern, &pattern_len, &flags, 
&options) == FAILURE) {
                        return;
                }
-#else
-               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Glob support is not 
available");
-               RETURN_FALSE;
-#endif
        } else {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa",
                                        &pattern, &pattern_len, &path, 
&path_len, &options) == FAILURE) {
@@ -1640,9 +1639,7 @@
        }

        if (type == 1) {
-#ifdef HAVE_GLOB
                found = php_zip_glob(pattern, pattern_len, flags, return_value 
TSRMLS_CC);
-#endif
        } else {
                found = php_zip_pcre(pattern, pattern_len, path, path_len, 
return_value TSRMLS_CC);
        }
@@ -1701,7 +1698,6 @@
 }
 /* }}} */

-#ifdef HAVE_GLOB
 /* {{{ proto bool ZipArchive::addGlob(string pattern[,int flags [, array 
options]])
 Add files matching the glob pattern. See php's glob for the pattern syntax. */
 static ZIPARCHIVE_METHOD(addGlob)
@@ -1709,7 +1705,6 @@
        php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
 }
 /* }}} */
-#endif

 /* {{{ proto bool ZipArchive::addPattern(string pattern[, string path [, array 
options]])
 Add files matching the pcre pattern. See php's pcre for the pattern syntax. */
@@ -2578,13 +2573,11 @@
        ZEND_ARG_INFO(0, dirname)
 ZEND_END_ARG_INFO()

-#ifdef HAVE_GLOB
 ZEND_BEGIN_ARG_INFO_EX(arginfo_ziparchive_addglob, 0, 0, 1)
        ZEND_ARG_INFO(0, pattern)
        ZEND_ARG_INFO(0, flags)
        ZEND_ARG_INFO(0, options)
 ZEND_END_ARG_INFO()
-#endif

 ZEND_BEGIN_ARG_INFO_EX(arginfo_ziparchive_addpattern, 0, 0, 1)
        ZEND_ARG_INFO(0, pattern)
@@ -2690,9 +2683,7 @@
        ZIPARCHIVE_ME(addEmptyDir,                      
arginfo_ziparchive_addemptydir, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(addFromString,            
arginfo_ziparchive_addfromstring, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(addFile,                          
arginfo_ziparchive_addfile, ZEND_ACC_PUBLIC)
-#ifdef HAVE_GLOB
        ZIPARCHIVE_ME(addGlob,                          
arginfo_ziparchive_addglob, ZEND_ACC_PUBLIC)
-#endif
        ZIPARCHIVE_ME(addPattern,                       
arginfo_ziparchive_addpattern, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(renameIndex,                      
arginfo_ziparchive_renameindex, ZEND_ACC_PUBLIC)
        ZIPARCHIVE_ME(renameName,                       
arginfo_ziparchive_renamename, ZEND_ACC_PUBLIC)

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

Reply via email to