pajoye          Sun Aug 13 23:39:57 2006 UTC

  Modified files:              
    /php-src/ext/zip    php_zip.c 
    /php-src/ext/zip/tests      oo_namelocate.phpt 
  Log:
  - locateName should not change the state/error, can be used to test
    an entry
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/zip/php_zip.c
diff -u php-src/ext/zip/php_zip.c:1.4 php-src/ext/zip/php_zip.c:1.5
--- php-src/ext/zip/php_zip.c:1.4       Sun Aug 13 20:54:27 2006
+++ php-src/ext/zip/php_zip.c   Sun Aug 13 23:39:57 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zip.c,v 1.4 2006/08/13 20:54:27 pajoye Exp $ */
+/* $Id: php_zip.c,v 1.5 2006/08/13 23:39:57 pajoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1126,6 +1126,7 @@
        char *name;
        int name_len;
        long flags = 0;
+       long idx = -1;
 
        if (!this) {
                RETURN_FALSE;
@@ -1142,7 +1143,18 @@
                RETURN_FALSE;
        }
 
-       RETURN_LONG((long)zip_name_locate(intern, (const char *)name, flags))
+       idx = (long)zip_name_locate(intern, (const char *)name, flags);
+
+       if (idx<0) {
+               /* reset the error */
+               if (intern->error.str) {
+                       _zip_error_fini(&intern->error);
+               }
+               _zip_error_init(&intern->error);
+               RETURN_FALSE;
+       } else {
+               RETURN_LONG(idx);
+       }
 }
 /* }}} */
 
@@ -1934,7 +1946,7 @@
        php_info_print_table_start();
 
        php_info_print_table_row(2, "Zip", "enabled");
-       php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.4 
2006/08/13 20:54:27 pajoye Exp $");
+       php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.5 
2006/08/13 23:39:57 pajoye Exp $");
        php_info_print_table_row(2, "Zip version", "1.4.0");
        php_info_print_table_row(2, "Libzip version", "0.7.1");
 
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_namelocate.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/zip/tests/oo_namelocate.phpt
diff -u php-src/ext/zip/tests/oo_namelocate.phpt:1.1 
php-src/ext/zip/tests/oo_namelocate.phpt:1.2
--- php-src/ext/zip/tests/oo_namelocate.phpt:1.1        Mon Jul 24 16:58:58 2006
+++ php-src/ext/zip/tests/oo_namelocate.phpt    Sun Aug 13 23:39:57 2006
@@ -2,7 +2,7 @@
 Locate entries by name
 --SKIPIF--
 <?php
-/* $Id: oo_namelocate.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */
+/* $Id: oo_namelocate.phpt,v 1.2 2006/08/13 23:39:57 pajoye Exp $ */
 if(!extension_loaded('zip')) die('skip');
 ?>
 --FILE--
@@ -31,15 +31,15 @@
        exit('failed');
 }
 
-echo $zip->locateName('entry1.txt') . "\n";
-echo $zip->locateName('eNtry2.txt') . "\n";
-echo $zip->locateName('eNtry2.txt', ZIPARCHIVE::FL_NOCASE) . "\n";
-echo $zip->locateName('enTRy2d.txt', 
ZIPARCHIVE::FL_NOCASE|ZIPARCHIVE::FL_NODIR) . "\n";
+var_dump($zip->locateName('entry1.txt'));
+var_dump($zip->locateName('eNtry2.txt'));
+var_dump($zip->locateName('eNtry2.txt', ZIPARCHIVE::FL_NOCASE));
+var_dump($zip->locateName('enTRy2d.txt', 
ZIPARCHIVE::FL_NOCASE|ZIPARCHIVE::FL_NODIR));
 $zip->close();
 
 ?>
 --EXPECTF--
-0
--1
-1
-2
+int(0)
+bool(false)
+int(1)
+int(2)

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

Reply via email to