helly Sat Nov 4 20:27:28 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/spl php_spl.c php_spl.h
Log:
- MFH Store length of autoload file exts
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.7&r2=1.52.2.28.2.8&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.7
php-src/ext/spl/php_spl.c:1.52.2.28.2.8
--- php-src/ext/spl/php_spl.c:1.52.2.28.2.7 Fri Nov 3 18:58:41 2006
+++ php-src/ext/spl/php_spl.c Sat Nov 4 20:27:28 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.52.2.28.2.7 2006/11/03 18:58:41 helly Exp $ */
+/* $Id: php_spl.c,v 1.52.2.28.2.8 2006/11/04 20:27:28 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -55,9 +55,10 @@
*/
static PHP_GINIT_FUNCTION(spl)
{
- spl_globals->autoload_extensions = NULL;
- spl_globals->autoload_functions = NULL;
- spl_globals->autoload_running = 0;
+ spl_globals->autoload_extensions = NULL;
+ spl_globals->autoload_extensions_len = 0;
+ spl_globals->autoload_functions = NULL;
+ spl_globals->autoload_running = 0;
}
/* }}} */
@@ -269,8 +270,8 @@
Default implementation for __autoload() */
PHP_FUNCTION(spl_autoload)
{
- char *class_name, *lc_name, *file_exts;
- int class_name_len, file_exts_len, found = 0;
+ char *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions);
+ int class_name_len, file_exts_len = SPL_G(autoload_extensions_len),
found = 0;
char *copy, *pos1, *pos2;
zval **original_return_value = EG(return_value_ptr_ptr);
zend_op **original_opline_ptr = EG(opline_ptr);
@@ -281,7 +282,7 @@
RETURN_FALSE;
}
- copy = pos1 = estrdup(ZEND_NUM_ARGS() > 1 ? file_exts :
SPL_G(autoload_extensions));
+ copy = pos1 = estrndup(file_exts, file_exts_len);
lc_name = zend_str_tolower_dup(class_name, class_name_len);
while(pos1 && *pos1 && !EG(exception)) {
EG(return_value_ptr_ptr) = original_return_value;
@@ -326,10 +327,11 @@
if (SPL_G(autoload_extensions)) {
efree(SPL_G(autoload_extensions));
}
- SPL_G(autoload_extensions) = estrdup(file_exts);
+ SPL_G(autoload_extensions) = estrndup(file_exts, file_exts_len);
+ SPL_G(autoload_extensions_len) = file_exts_len;
}
- RETURN_STRING(SPL_G(autoload_extensions), 1);
+ RETURN_STRINGL(SPL_G(autoload_extensions),
SPL_G(autoload_extensions_len), 1);
} /* }}} */
typedef struct {
@@ -696,6 +698,7 @@
PHP_RINIT_FUNCTION(spl) /* {{{ */
{
SPL_G(autoload_extensions) = estrndup(".inc,.php",
sizeof(".inc,.php")-1);
+ SPL_G(autoload_extensions_len) = sizeof(".inc,.php")-1;
SPL_G(autoload_functions) = NULL;
return SUCCESS;
} /* }}} */
@@ -705,6 +708,7 @@
if (SPL_G(autoload_extensions)) {
efree(SPL_G(autoload_extensions));
SPL_G(autoload_extensions) = NULL;
+ SPL_G(autoload_extensions_len) = 0;
}
if (SPL_G(autoload_functions)) {
zend_hash_destroy(SPL_G(autoload_functions));
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.17.2.1.2.1&r2=1.17.2.1.2.2&diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.17.2.1.2.1
php-src/ext/spl/php_spl.h:1.17.2.1.2.2
--- php-src/ext/spl/php_spl.h:1.17.2.1.2.1 Fri Nov 3 18:58:41 2006
+++ php-src/ext/spl/php_spl.h Sat Nov 4 20:27:28 2006
@@ -59,6 +59,7 @@
char * autoload_extensions;
HashTable * autoload_functions;
int autoload_running;
+ int autoload_extensions_len;
ZEND_END_MODULE_GLOBALS(spl)
#ifdef ZTS
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php