cvs: php-src /ext/spl php_spl.c /ext/spl/tests spl_autoload_001.phpt

From: Date: Wed, 02 Mar 2005 20:59:06 +0000
Subject: cvs: php-src /ext/spl php_spl.c /ext/spl/tests spl_autoload_001.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-30691@lists.php.net to get a copy of this message
helly Wed Mar 2 15:59:06 2005 EDT Modified files: /php-src/ext/spl php_spl.c /php-src/ext/spl/tests spl_autoload_001.phpt Log: - Let spl_autoload_extensions() always return what's registered http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.41&r2=1.42&ty=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.41 php-src/ext/spl/php_spl.c:1.42 --- php-src/ext/spl/php_spl.c:1.41 Tue Mar 1 20:14:40 2005 +++ php-src/ext/spl/php_spl.c Wed Mar 2 15:59:05 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c,v 1.41 2005/03/02 01:14:40 helly Exp $ */ +/* $Id: php_spl.c,v 1.42 2005/03/02 20:59:05 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -242,21 +242,25 @@ } } /* }}} */ -/* {{{ void spl_autoload_extensions(string file_extensions]) - Register default file extensions for spl_autoload */ +/* {{{ void string spl_autoload_extensions([string file_extensions]) + Register and return default file extensions for spl_autoload */ PHP_FUNCTION(spl_autoload_extensions) { char *file_exts; int file_exts_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file_exts, &file_exts_len) == FAILURE) { - return; + if (ZEND_NUM_ARGS() > 0) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file_exts, &file_exts_len) == FAILURE) { + return; + } + + if (SPL_G(autoload_extensions)) { + efree(SPL_G(autoload_extensions)); + } + SPL_G(autoload_extensions) = estrdup(file_exts); } - if (SPL_G(autoload_extensions)) { - efree(SPL_G(autoload_extensions)); - } - SPL_G(autoload_extensions) = estrdup(file_exts); + RETURN_STRING(SPL_G(autoload_extensions), 1); } /* }}} */ /* {{{ void spl_autoload_call(string class_name) http://cvs.php.net/diff.php/php-src/ext/spl/tests/spl_autoload_001.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/spl/tests/spl_autoload_001.phpt diff -u php-src/ext/spl/tests/spl_autoload_001.phpt:1.1 php-src/ext/spl/tests/spl_autoload_001.phpt:1.2 --- php-src/ext/spl/tests/spl_autoload_001.phpt:1.1 Tue Mar 1 20:14:41 2005 +++ php-src/ext/spl/tests/spl_autoload_001.phpt Wed Mar 2 15:59:06 2005 @@ -1,5 +1,5 @@ --TEST-- -SPL spl_autoload() and friends +SPL: spl_autoload() and friends --INI-- include_path=. --FILE-- @@ -7,6 +7,8 @@ echo "===EMPTY===\n"; +var_dump(spl_autoload_extensions()); + try { spl_autoload("TestClass"); @@ -57,7 +59,7 @@ try { - spl_autoload_extensions(".inc"); + var_dump(spl_autoload_extensions(".inc")); var_dump(class_exists("TestClass", true)); } catch(Exception $e) @@ -102,6 +104,7 @@ <?php exit(0); ?> --EXPECTF-- ===EMPTY=== +string(13) ".inc,.inc.php" %stestclass.inc Exception: Class TestClass could not be loaded ===()=== @@ -116,6 +119,7 @@ Exception: Class TestClass could not be loaded Exception: Class TestClass could not be loaded ===SPL_AUTOLOAD()=== +string(4) ".inc" Exception: Class TestClass could not be loaded ===REGISTER=== TestFunc1(TestClass)

« previous php.cvs (#30691) next »