summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2006-11-04 20:27:28 +0000
committerMarcus Boerger <helly@php.net>2006-11-04 20:27:28 +0000
commit15592390c591cb38da770c73ab4feb28e70627dd (patch)
treef6963bfcd76b9690813069f98ec231ae2476abc5
parent9df320c423a8e3d00d0b69a144c8a4a8617de39c (diff)
downloadphp-git-15592390c591cb38da770c73ab4feb28e70627dd.tar.gz
- MFH Store length of autoload file exts
-rwxr-xr-xext/spl/php_spl.c20
-rwxr-xr-xext/spl/php_spl.h1
2 files changed, 13 insertions, 8 deletions
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 75ea892658..95a8a032ee 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -55,9 +55,10 @@ zend_function_entry spl_functions_none[] = {
*/
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 @@ int spl_autoload(const char *class_name, const char * lc_name, int class_name_le
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 @@ PHP_FUNCTION(spl_autoload)
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 @@ PHP_FUNCTION(spl_autoload_extensions)
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_MINIT_FUNCTION(spl)
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 @@ PHP_RSHUTDOWN_FUNCTION(spl) /* {{{ */
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));
diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h
index fd8e5cb8b9..88f99d44d8 100755
--- a/ext/spl/php_spl.h
+++ b/ext/spl/php_spl.h
@@ -59,6 +59,7 @@ ZEND_BEGIN_MODULE_GLOBALS(spl)
char * autoload_extensions;
HashTable * autoload_functions;
int autoload_running;
+ int autoload_extensions_len;
ZEND_END_MODULE_GLOBALS(spl)
#ifdef ZTS