helly           Sat Nov  4 20:22:29 2006 UTC

  Modified files:              
    /php-src/ext/spl    php_spl.c php_spl.h 
  Log:
  - Store length of autoload file exts
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.98&r2=1.99&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.98 php-src/ext/spl/php_spl.c:1.99
--- php-src/ext/spl/php_spl.c:1.98      Sat Nov  4 20:12:26 2006
+++ php-src/ext/spl/php_spl.c   Sat Nov  4 20:22:29 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c,v 1.98 2006/11/04 20:12:26 helly Exp $ */
+/* $Id: php_spl.c,v 1.99 2006/11/04 20:22:29 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;
 }
 /* }}} */
 
@@ -267,8 +268,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);
@@ -279,7 +280,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;
@@ -324,10 +325,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 {
@@ -707,7 +709,9 @@
 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;
+       SPL_G(autoload_running) = 0;
        return SUCCESS;
 } /* }}} */
 
@@ -716,6 +720,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.19&r2=1.20&diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.19 php-src/ext/spl/php_spl.h:1.20
--- php-src/ext/spl/php_spl.h:1.19      Tue Oct 31 23:18:00 2006
+++ php-src/ext/spl/php_spl.h   Sat Nov  4 20:22:29 2006
@@ -57,6 +57,7 @@
 
 ZEND_BEGIN_MODULE_GLOBALS(spl)
        char *       autoload_extensions;
+       int          autoload_extensions_len;
        HashTable *  autoload_functions;
        int          autoload_running;
 ZEND_END_MODULE_GLOBALS(spl)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to