cellog Sun Jun 15 21:15:29 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/phar phar.c phar.phar phar_internal.h phar_object.c
Log:
minor optimization
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.16&r2=1.370.2.17&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.16 php-src/ext/phar/phar.c:1.370.2.17
--- php-src/ext/phar/phar.c:1.370.2.16 Sun Jun 15 18:15:48 2008
+++ php-src/ext/phar/phar.c Sun Jun 15 21:15:29 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.370.2.16 2008/06/15 18:15:48 cellog Exp $ */
+/* $Id: phar.c,v 1.370.2.17 2008/06/15 21:15:29 cellog Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -1148,11 +1148,11 @@
}
/* first try to open an existing file */
- if (phar_detect_phar_fname_ext(fname, 1, &ext_str, &ext_len, !is_data,
0, 1 TSRMLS_CC) == SUCCESS) {
+ if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len,
!is_data, 0, 1 TSRMLS_CC) == SUCCESS) {
goto check_file;
}
/* next try to create a new file */
- if (FAILURE == phar_detect_phar_fname_ext(fname, 1, &ext_str, &ext_len,
!is_data, 1, 1 TSRMLS_CC)) {
+ if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str,
&ext_len, !is_data, 1, 1 TSRMLS_CC)) {
if (error) {
spprintf(error, 0, "Cannot create phar '%s', file
extension (or combination) not recognised", fname);
}
@@ -1712,10 +1712,9 @@
* the last parameter should be set to tell the thing to assume that filename
is the full path, and only to check the
* extension rules, not to iterate.
*/
-int phar_detect_phar_fname_ext(const char *filename, int check_length, const
char **ext_str, int *ext_len, int executable, int for_create, int is_complete
TSRMLS_DC) /* {{{ */
+int phar_detect_phar_fname_ext(const char *filename, int filename_len, const
char **ext_str, int *ext_len, int executable, int for_create, int is_complete
TSRMLS_DC) /* {{{ */
{
const char *pos, *slash;
- int filename_len = strlen(filename);
*ext_str = NULL;
@@ -1724,7 +1723,7 @@
}
phar_request_initialize(TSRMLS_C);
/* first check for alias in first segment */
- pos = strchr(filename, '/');
+ pos = memchr(filename, '/', filename_len);
if (pos && pos != filename) {
if (zend_hash_exists(&(PHAR_GLOBALS->phar_alias_map), (char *)
filename, pos - filename)) {
*ext_str = pos;
@@ -1783,19 +1782,19 @@
}
}
- pos = strchr(filename + 1, '.');
+ pos = memchr(filename + 1, '.', filename_len);
next_extension:
if (!pos) {
return FAILURE;
}
while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) {
- pos = strchr(pos + 1, '.');
+ pos = memchr(pos + 1, '.', filename_len - (pos - filename) + 1);
if (!pos) {
return FAILURE;
}
}
- slash = strchr(pos, '/');
+ slash = memchr(pos, '/', filename_len - (pos - filename));
if (!slash) {
/* this is a url like "phar://blah.phar" with no directory */
*ext_str = pos;
@@ -1997,7 +1996,7 @@
filename = estrndup(filename, filename_len);
phar_unixify_path_separators(filename, filename_len);
#endif
- if (phar_detect_phar_fname_ext(filename, 0, &ext_str, &ext_len,
executable, for_create, 0 TSRMLS_CC) == FAILURE) {
+ if (phar_detect_phar_fname_ext(filename, filename_len, &ext_str,
&ext_len, executable, for_create, 0 TSRMLS_CC) == FAILURE) {
if (ext_len != -1) {
if (!ext_str) {
/* no / detected, restore arch for error
message */
@@ -3398,7 +3397,7 @@
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
- php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.16 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.17 $");
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.phar?r1=1.7.2.15&r2=1.7.2.16&diff_format=u
Index: php-src/ext/phar/phar.phar
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_internal.h?r1=1.109.2.12&r2=1.109.2.13&diff_format=u
Index: php-src/ext/phar/phar_internal.h
diff -u php-src/ext/phar/phar_internal.h:1.109.2.12
php-src/ext/phar/phar_internal.h:1.109.2.13
--- php-src/ext/phar/phar_internal.h:1.109.2.12 Sun Jun 15 18:15:48 2008
+++ php-src/ext/phar/phar_internal.h Sun Jun 15 21:15:29 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_internal.h,v 1.109.2.12 2008/06/15 18:15:48 cellog Exp $ */
+/* $Id: phar_internal.h,v 1.109.2.13 2008/06/15 21:15:29 cellog Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -472,7 +472,7 @@
phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len,
char *path, int path_len, char *mode, char allow_dir, char **error, int
security TSRMLS_DC);
int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len,
char *path, int path_len, char *mode, char allow_dir, char **error, int
security TSRMLS_DC);
int phar_flush(phar_archive_data *archive, char *user_stub, long len, int
convert, char **error TSRMLS_DC);
-int phar_detect_phar_fname_ext(const char *filename, int check_length, const
char **ext_str, int *ext_len, int executable, int for_create, int is_complete
TSRMLS_DC);
+int phar_detect_phar_fname_ext(const char *filename, int filename_len, const
char **ext_str, int *ext_len, int executable, int for_create, int is_complete
TSRMLS_DC);
int phar_split_fname(char *filename, int filename_len, char **arch, int
*arch_len, char **entry, int *entry_len, int executable, int for_create
TSRMLS_DC);
typedef enum {
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266.2.20&r2=1.266.2.21&diff_format=u
Index: php-src/ext/phar/phar_object.c
diff -u php-src/ext/phar/phar_object.c:1.266.2.20
php-src/ext/phar/phar_object.c:1.266.2.21
--- php-src/ext/phar/phar_object.c:1.266.2.20 Sun Jun 15 18:15:48 2008
+++ php-src/ext/phar/phar_object.c Sun Jun 15 21:15:29 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_object.c,v 1.266.2.20 2008/06/15 18:15:48 cellog Exp $ */
+/* $Id: phar_object.c,v 1.266.2.21 2008/06/15 21:15:29 cellog Exp $ */
#include "phar_internal.h"
#include "func_interceptors.h"
@@ -1064,15 +1064,15 @@
{
char *fname;
const char *ext_str;
- int fname_len, ext_len;
+ int fname_len, ext_len, is_executable;
zend_bool executable = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &fname,
&fname_len, &executable) == FAILURE) {
return;
}
- fname_len = executable;
- RETVAL_BOOL(phar_detect_phar_fname_ext(fname, 1, &ext_str, &ext_len,
fname_len, 2, 1 TSRMLS_CC) == SUCCESS);
+ is_executable = executable;
+ RETVAL_BOOL(phar_detect_phar_fname_ext(fname, fname_len, &ext_str,
&ext_len, is_executable, 2, 1 TSRMLS_CC) == SUCCESS);
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php