pajoye Sun Aug 13 23:43:11 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zip php_zip.c /php-src/ext/zip/tests oo_namelocate.phpt Log: - MFH: 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.1.2.3&r2=1.1.2.4&diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.3 php-src/ext/zip/php_zip.c:1.1.2.4 --- php-src/ext/zip/php_zip.c:1.1.2.3 Sun Aug 13 21:09:59 2006 +++ php-src/ext/zip/php_zip.c Sun Aug 13 23:43:11 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_zip.c,v 1.1.2.3 2006/08/13 21:09:59 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.4 2006/08/13 23:43:11 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1153,6 +1153,7 @@ char *name; int name_len; long flags = 0; + long idx = -1; if (!this) { RETURN_FALSE; @@ -1169,7 +1170,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); + } } /* }}} */ @@ -1961,7 +1973,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.1.2.3 2006/08/13 21:09:59 pajoye Exp $"); + php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.4 2006/08/13 23:43:11 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.1.2.1&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.1.2.1 --- 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:43:11 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.1.2.1 2006/08/13 23:43:11 pajoye Exp $ */ if(!extension_loaded('zip')) die('skip'); ?> --FILE-- @@ -31,15 +31,16 @@ 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