[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h

2009-01-26 Thread Etienne Kneuss
colder  Mon Jan 26 11:37:50 2009 UTC

  Modified files:  
/php-src/ext/splphp_spl.c php_spl.h 
  Log:
  Improve spl_object_hash()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.149r2=1.150diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.149 php-src/ext/spl/php_spl.c:1.150
--- php-src/ext/spl/php_spl.c:1.149 Wed Dec 31 11:12:36 2008
+++ php-src/ext/spl/php_spl.c   Mon Jan 26 11:37:46 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_spl.c,v 1.149 2008/12/31 11:12:36 sebastian Exp $ */
+/* $Id: php_spl.c,v 1.150 2009/01/26 11:37:46 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -39,7 +39,9 @@
 #include spl_fixedarray.h
 #include zend_exceptions.h
 #include zend_interfaces.h
-#include ext/standard/md5.h
+#include ext/standard/php_rand.h
+#include ext/standard/php_lcg.h
+#include main/snprintf.h
 
 #ifdef COMPILE_DL_SPL
 ZEND_GET_MODULE(spl)
@@ -689,34 +691,41 @@
 PHP_FUNCTION(spl_object_hash)
 {
zval *obj;
-   char* md5str;
+   char* hash;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, o, obj) == 
FAILURE) {
return;
}
 
-   md5str = emalloc(33);
-   php_spl_object_hash(obj, md5str TSRMLS_CC);
+   hash = emalloc(33);
+   php_spl_object_hash(obj, hash TSRMLS_CC);
 
-   RETVAL_STRING(md5str, 0);
+   RETVAL_STRING(hash, 0);
 }
 /* }}} */
 
-PHPAPI void php_spl_object_hash(zval *obj, char *md5str TSRMLS_DC) /* {{{*/
+PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/
 {
-   int len;
-   char *hash;
-   PHP_MD5_CTX context;
-   unsigned char digest[16];
-
-   len = spprintf(hash, 0, %p:%d, Z_OBJ_HT_P(obj), Z_OBJ_HANDLE_P(obj));
-   
-   md5str[0] = '\0';
-   PHP_MD5Init(context);
-   PHP_MD5Update(context, (unsigned char*)hash, len);
-   PHP_MD5Final(digest, context);
-   make_digest(md5str, digest);
-   efree(hash);
+   intptr_t hash_handle, hash_handlers;
+   char *hex;
+
+   if (!SPL_G(hash_mask_init)) {
+   if (!BG(mt_rand_is_seeded)) {
+   php_mt_srand(GENERATE_SEED() TSRMLS_CC);
+   }
+
+   SPL_G(hash_mask_handle)   = (intptr_t)(php_mt_rand(TSRMLS_C)  
1);
+   SPL_G(hash_mask_handlers) = (intptr_t)(php_mt_rand(TSRMLS_C)  
1);
+   SPL_G(hash_mask_init) = 1;
+   }
+
+   hash_handle   = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj);
+   hash_handlers = SPL_G(hash_mask_handlers)^(intptr_t)Z_OBJ_HT_P(obj);
+
+   spprintf(hex, 32, %016x%016x, hash_handle, hash_handlers);
+
+   strlcpy(result, hex, 33);
+   efree(hex);
 }
 /* }}} */
 
@@ -865,6 +874,8 @@
ZVAL_ASCII_STRINGL(SPL_G(autoload_extensions), .inc,.php, 
sizeof(.inc,.php)-1, 1);
SPL_G(autoload_functions) = NULL;
SPL_G(autoload_running) = 0;
+   SPL_G(autoload_running) = 0;
+   SPL_G(hash_mask_init) = 0;
return SUCCESS;
 } /* }}} */
 
@@ -879,6 +890,9 @@
FREE_HASHTABLE(SPL_G(autoload_functions));
SPL_G(autoload_functions) = NULL;
}
+   if (SPL_G(hash_mask_init)) {
+   SPL_G(hash_mask_init) = 0;
+   }
return SUCCESS;
 } /* }}} */
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.28r2=1.29diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.28 php-src/ext/spl/php_spl.h:1.29
--- php-src/ext/spl/php_spl.h:1.28  Wed Dec 31 11:12:36 2008
+++ php-src/ext/spl/php_spl.h   Mon Jan 26 11:37:46 2009
@@ -61,6 +61,9 @@
zval autoload_extensions;
HashTable *  autoload_functions;
int  autoload_running;
+   intptr_t hash_mask_handle;
+   intptr_t hash_mask_handlers;
+   int  hash_mask_init;
 ZEND_END_MODULE_GLOBALS(spl)
 
 #ifdef ZTS



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



[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c

2008-01-27 Thread Marcus Boerger
helly   Sun Jan 27 15:03:55 2008 UTC

  Modified files:  
/php-src/ext/splphp_spl.c php_spl.h 
/php-src/ext/tidy   php_tidy.h tidy.c 
  Log:
  - revert over constfying
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.121r2=1.122diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.121 php-src/ext/spl/php_spl.c:1.122
--- php-src/ext/spl/php_spl.c:1.121 Fri Jan 25 20:30:36 2008
+++ php-src/ext/spl/php_spl.c   Sun Jan 27 15:03:55 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_spl.c,v 1.121 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: php_spl.c,v 1.122 2008/01/27 15:03:55 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -781,7 +781,7 @@
 
 /* {{{ spl_module_entry
  */
-const zend_module_entry spl_module_entry = {
+zend_module_entry spl_module_entry = {
 #ifdef HAVE_SIMPLEXML
STANDARD_MODULE_HEADER_EX, NULL,
spl_deps,
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.25r2=1.26diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.25 php-src/ext/spl/php_spl.h:1.26
--- php-src/ext/spl/php_spl.h:1.25  Fri Jan 25 20:30:36 2008
+++ php-src/ext/spl/php_spl.h   Sun Jan 27 15:03:55 2008
@@ -28,7 +28,7 @@
 #define SPL_DEBUG(x)
 #endif
 
-extern const zend_module_entry spl_module_entry;
+extern zend_module_entry spl_module_entry;
 #define phpext_spl_ptr spl_module_entry
 
 #ifdef PHP_WIN32
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.37r2=1.38diff_format=u
Index: php-src/ext/tidy/php_tidy.h
diff -u php-src/ext/tidy/php_tidy.h:1.37 php-src/ext/tidy/php_tidy.h:1.38
--- php-src/ext/tidy/php_tidy.h:1.37Fri Jan 25 20:30:36 2008
+++ php-src/ext/tidy/php_tidy.h Sun Jan 27 15:03:55 2008
@@ -16,12 +16,12 @@
   +--+
 */
 
-/* $Id: php_tidy.h,v 1.37 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: php_tidy.h,v 1.38 2008/01/27 15:03:55 helly Exp $ */
 
 #ifndef PHP_TIDY_H
 #define PHP_TIDY_H
 
-extern const zend_module_entry tidy_module_entry;
+extern zend_module_entry tidy_module_entry;
 #define phpext_tidy_ptr tidy_module_entry
 
 #define TIDY_METHOD_MAP(name, func_name, arg_types) \
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.119r2=1.120diff_format=u
Index: php-src/ext/tidy/tidy.c
diff -u php-src/ext/tidy/tidy.c:1.119 php-src/ext/tidy/tidy.c:1.120
--- php-src/ext/tidy/tidy.c:1.119   Fri Jan 25 20:30:36 2008
+++ php-src/ext/tidy/tidy.c Sun Jan 27 15:03:55 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -359,7 +359,7 @@
 static zend_object_handlers tidy_object_handlers_doc;
 static zend_object_handlers tidy_object_handlers_node;
 
-const zend_module_entry tidy_module_entry = {
+zend_module_entry tidy_module_entry = {
STANDARD_MODULE_HEADER,
tidy,
tidy_functions,
@@ -1062,7 +1062,7 @@
php_info_print_table_start();
php_info_print_table_header(2, Tidy support, enabled);
php_info_print_table_row(2, libTidy Release, (char 
*)tidyReleaseDate());
-   php_info_print_table_row(2, Extension Version, 
PHP_TIDY_MODULE_VERSION  ($Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp 
$));
+   php_info_print_table_row(2, Extension Version, 
PHP_TIDY_MODULE_VERSION  ($Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp 
$));
php_info_print_table_end();
 
DISPLAY_INI_ENTRIES();

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



Re: [PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c

2008-01-27 Thread Nuno Lopes
Thank you for reverting this. It seems that the Zend engine really requires 
right access to these structures. The engine needs fixing first.

Thanks,
Nuno

- Original Message - 
From: Marcus Boerger [EMAIL PROTECTED]

To: php-cvs@lists.php.net
Sent: Sunday, January 27, 2008 3:03 PM
Subject: [PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy 
php_tidy.h tidy.c




helly Sun Jan 27 15:03:55 2008 UTC

 Modified files:
   /php-src/ext/spl php_spl.c php_spl.h
   /php-src/ext/tidy php_tidy.h tidy.c
 Log:
 - revert over constfying

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.121r2=1.122diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.121 php-src/ext/spl/php_spl.c:1.122
--- php-src/ext/spl/php_spl.c:1.121 Fri Jan 25 20:30:36 2008
+++ php-src/ext/spl/php_spl.c Sun Jan 27 15:03:55 2008
@@ -16,7 +16,7 @@

+--+
 */

-/* $Id: php_spl.c,v 1.121 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: php_spl.c,v 1.122 2008/01/27 15:03:55 helly Exp $ */

#ifdef HAVE_CONFIG_H
#include config.h
@@ -781,7 +781,7 @@

/* {{{ spl_module_entry
 */
-const zend_module_entry spl_module_entry = {
+zend_module_entry spl_module_entry = {
#ifdef HAVE_SIMPLEXML
 STANDARD_MODULE_HEADER_EX, NULL,
 spl_deps,
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.25r2=1.26diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.25 php-src/ext/spl/php_spl.h:1.26
--- php-src/ext/spl/php_spl.h:1.25 Fri Jan 25 20:30:36 2008
+++ php-src/ext/spl/php_spl.h Sun Jan 27 15:03:55 2008
@@ -28,7 +28,7 @@
#define SPL_DEBUG(x)
#endif

-extern const zend_module_entry spl_module_entry;
+extern zend_module_entry spl_module_entry;
#define phpext_spl_ptr spl_module_entry

#ifdef PHP_WIN32
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.37r2=1.38diff_format=u
Index: php-src/ext/tidy/php_tidy.h
diff -u php-src/ext/tidy/php_tidy.h:1.37 php-src/ext/tidy/php_tidy.h:1.38
--- php-src/ext/tidy/php_tidy.h:1.37 Fri Jan 25 20:30:36 2008
+++ php-src/ext/tidy/php_tidy.h Sun Jan 27 15:03:55 2008
@@ -16,12 +16,12 @@
  +--+
*/

-/* $Id: php_tidy.h,v 1.37 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: php_tidy.h,v 1.38 2008/01/27 15:03:55 helly Exp $ */

#ifndef PHP_TIDY_H
#define PHP_TIDY_H

-extern const zend_module_entry tidy_module_entry;
+extern zend_module_entry tidy_module_entry;
#define phpext_tidy_ptr tidy_module_entry

#define TIDY_METHOD_MAP(name, func_name, arg_types) \
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.119r2=1.120diff_format=u
Index: php-src/ext/tidy/tidy.c
diff -u php-src/ext/tidy/tidy.c:1.119 php-src/ext/tidy/tidy.c:1.120
--- php-src/ext/tidy/tidy.c:1.119 Fri Jan 25 20:30:36 2008
+++ php-src/ext/tidy/tidy.c Sun Jan 27 15:03:55 2008
@@ -16,7 +16,7 @@
  +--+
*/

-/* $Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp $ */

#ifdef HAVE_CONFIG_H
#include config.h
@@ -359,7 +359,7 @@
static zend_object_handlers tidy_object_handlers_doc;
static zend_object_handlers tidy_object_handlers_node;

-const zend_module_entry tidy_module_entry = {
+zend_module_entry tidy_module_entry = {
 STANDARD_MODULE_HEADER,
 tidy,
 tidy_functions,
@@ -1062,7 +1062,7 @@
 php_info_print_table_start();
 php_info_print_table_header(2, Tidy support, enabled);
 php_info_print_table_row(2, libTidy Release, (char 
*)tidyReleaseDate());
- php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION 
 ($Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $));
+ php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION 
 ($Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp $));

 php_info_print_table_end();

 DISPLAY_INI_ENTRIES();

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


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



Re: [PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c

2008-01-27 Thread Marcus Boerger
Hello Nuno,

  it writes the module number in the structure. We could have the macros
create a static non const int that receives the module number and reference
that from the struct via a pointer, which would be compatible to the struct
being static const then.

marcus

Sunday, January 27, 2008, 6:08:47 PM, you wrote:

 Thank you for reverting this. It seems that the Zend engine really requires 
 right access to these structures. The engine needs fixing first.
 Thanks,
 Nuno

 - Original Message - 
 From: Marcus Boerger [EMAIL PROTECTED]
 To: php-cvs@lists.php.net
 Sent: Sunday, January 27, 2008 3:03 PM
 Subject: [PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy 
 php_tidy.h tidy.c


 helly Sun Jan 27 15:03:55 2008 UTC

  Modified files:
/php-src/ext/spl php_spl.c php_spl.h
/php-src/ext/tidy php_tidy.h tidy.c
  Log:
  - revert over constfying

 http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.121r2=1.122diff_format=u
 Index: php-src/ext/spl/php_spl.c
 diff -u php-src/ext/spl/php_spl.c:1.121 php-src/ext/spl/php_spl.c:1.122
 --- php-src/ext/spl/php_spl.c:1.121 Fri Jan 25 20:30:36 2008
 +++ php-src/ext/spl/php_spl.c Sun Jan 27 15:03:55 2008
 @@ -16,7 +16,7 @@
 
 +--+
  */

 -/* $Id: php_spl.c,v 1.121 2008/01/25 20:30:36 nlopess Exp $ */
 +/* $Id: php_spl.c,v 1.122 2008/01/27 15:03:55 helly Exp $ */

 #ifdef HAVE_CONFIG_H
 #include config.h
 @@ -781,7 +781,7 @@

 /* {{{ spl_module_entry
  */
 -const zend_module_entry spl_module_entry = {
 +zend_module_entry spl_module_entry = {
 #ifdef HAVE_SIMPLEXML
  STANDARD_MODULE_HEADER_EX, NULL,
  spl_deps,
 http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.25r2=1.26diff_format=u
 Index: php-src/ext/spl/php_spl.h
 diff -u php-src/ext/spl/php_spl.h:1.25 php-src/ext/spl/php_spl.h:1.26
 --- php-src/ext/spl/php_spl.h:1.25 Fri Jan 25 20:30:36 2008
 +++ php-src/ext/spl/php_spl.h Sun Jan 27 15:03:55 2008
 @@ -28,7 +28,7 @@
 #define SPL_DEBUG(x)
 #endif

 -extern const zend_module_entry spl_module_entry;
 +extern zend_module_entry spl_module_entry;
 #define phpext_spl_ptr spl_module_entry

 #ifdef PHP_WIN32
 http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.37r2=1.38diff_format=u
 Index: php-src/ext/tidy/php_tidy.h
 diff -u php-src/ext/tidy/php_tidy.h:1.37 php-src/ext/tidy/php_tidy.h:1.38
 --- php-src/ext/tidy/php_tidy.h:1.37 Fri Jan 25 20:30:36 2008
 +++ php-src/ext/tidy/php_tidy.h Sun Jan 27 15:03:55 2008
 @@ -16,12 +16,12 @@
   +--+
 */

 -/* $Id: php_tidy.h,v 1.37 2008/01/25 20:30:36 nlopess Exp $ */
 +/* $Id: php_tidy.h,v 1.38 2008/01/27 15:03:55 helly Exp $ */

 #ifndef PHP_TIDY_H
 #define PHP_TIDY_H

 -extern const zend_module_entry tidy_module_entry;
 +extern zend_module_entry tidy_module_entry;
 #define phpext_tidy_ptr tidy_module_entry

 #define TIDY_METHOD_MAP(name, func_name, arg_types) \
 http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.119r2=1.120diff_format=u
 Index: php-src/ext/tidy/tidy.c
 diff -u php-src/ext/tidy/tidy.c:1.119 php-src/ext/tidy/tidy.c:1.120
 --- php-src/ext/tidy/tidy.c:1.119 Fri Jan 25 20:30:36 2008
 +++ php-src/ext/tidy/tidy.c Sun Jan 27 15:03:55 2008
 @@ -16,7 +16,7 @@
   +--+
 */

 -/* $Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $ */
 +/* $Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp $ */

 #ifdef HAVE_CONFIG_H
 #include config.h
 @@ -359,7 +359,7 @@
 static zend_object_handlers tidy_object_handlers_doc;
 static zend_object_handlers tidy_object_handlers_node;

 -const zend_module_entry tidy_module_entry = {
 +zend_module_entry tidy_module_entry = {
  STANDARD_MODULE_HEADER,
  tidy,
  tidy_functions,
 @@ -1062,7 +1062,7 @@
  php_info_print_table_start();
  php_info_print_table_header(2, Tidy support, enabled);
  php_info_print_table_row(2, libTidy Release, (char 
 *)tidyReleaseDate());
 - php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION 
  ($Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $));
 + php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION 
  ($Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp $));
  php_info_print_table_end();

  DISPLAY_INI_ENTRIES();

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




Best regards,
 Marcus

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



Re: [PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c

2008-01-27 Thread Nuno Lopes
I'll take a look into that to see how feasible it is and if it presents any 
useful gains.


Thanks,
Nuno


- Original Message -

Hello Nuno,

 it writes the module number in the structure. We could have the macros
create a static non const int that receives the module number and 
reference
that from the struct via a pointer, which would be compatible to the 
struct

being static const then.

marcus

Sunday, January 27, 2008, 6:08:47 PM, you wrote:

Thank you for reverting this. It seems that the Zend engine really 
requires

right access to these structures. The engine needs fixing first.
Thanks,
Nuno


- Original Message - 
From: Marcus Boerger [EMAIL PROTECTED]

To: php-cvs@lists.php.net
Sent: Sunday, January 27, 2008 3:03 PM
Subject: [PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy
php_tidy.h tidy.c




helly Sun Jan 27 15:03:55 2008 UTC

 Modified files:
   /php-src/ext/spl php_spl.c php_spl.h
   /php-src/ext/tidy php_tidy.h tidy.c
 Log:
 - revert over constfying

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.121r2=1.122diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.121 php-src/ext/spl/php_spl.c:1.122
--- php-src/ext/spl/php_spl.c:1.121 Fri Jan 25 20:30:36 2008
+++ php-src/ext/spl/php_spl.c Sun Jan 27 15:03:55 2008
@@ -16,7 +16,7 @@

+--+
 */

-/* $Id: php_spl.c,v 1.121 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: php_spl.c,v 1.122 2008/01/27 15:03:55 helly Exp $ */

#ifdef HAVE_CONFIG_H
#include config.h
@@ -781,7 +781,7 @@

/* {{{ spl_module_entry
 */
-const zend_module_entry spl_module_entry = {
+zend_module_entry spl_module_entry = {
#ifdef HAVE_SIMPLEXML
 STANDARD_MODULE_HEADER_EX, NULL,
 spl_deps,
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.25r2=1.26diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.25 php-src/ext/spl/php_spl.h:1.26
--- php-src/ext/spl/php_spl.h:1.25 Fri Jan 25 20:30:36 2008
+++ php-src/ext/spl/php_spl.h Sun Jan 27 15:03:55 2008
@@ -28,7 +28,7 @@
#define SPL_DEBUG(x)
#endif

-extern const zend_module_entry spl_module_entry;
+extern zend_module_entry spl_module_entry;
#define phpext_spl_ptr spl_module_entry

#ifdef PHP_WIN32
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.37r2=1.38diff_format=u
Index: php-src/ext/tidy/php_tidy.h
diff -u php-src/ext/tidy/php_tidy.h:1.37 
php-src/ext/tidy/php_tidy.h:1.38

--- php-src/ext/tidy/php_tidy.h:1.37 Fri Jan 25 20:30:36 2008
+++ php-src/ext/tidy/php_tidy.h Sun Jan 27 15:03:55 2008
@@ -16,12 +16,12 @@

+--+
*/

-/* $Id: php_tidy.h,v 1.37 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: php_tidy.h,v 1.38 2008/01/27 15:03:55 helly Exp $ */

#ifndef PHP_TIDY_H
#define PHP_TIDY_H

-extern const zend_module_entry tidy_module_entry;
+extern zend_module_entry tidy_module_entry;
#define phpext_tidy_ptr tidy_module_entry

#define TIDY_METHOD_MAP(name, func_name, arg_types) \
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.119r2=1.120diff_format=u
Index: php-src/ext/tidy/tidy.c
diff -u php-src/ext/tidy/tidy.c:1.119 php-src/ext/tidy/tidy.c:1.120
--- php-src/ext/tidy/tidy.c:1.119 Fri Jan 25 20:30:36 2008
+++ php-src/ext/tidy/tidy.c Sun Jan 27 15:03:55 2008
@@ -16,7 +16,7 @@

+--+
*/

-/* $Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $ */
+/* $Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp $ */

#ifdef HAVE_CONFIG_H
#include config.h
@@ -359,7 +359,7 @@
static zend_object_handlers tidy_object_handlers_doc;
static zend_object_handlers tidy_object_handlers_node;

-const zend_module_entry tidy_module_entry = {
+zend_module_entry tidy_module_entry = {
 STANDARD_MODULE_HEADER,
 tidy,
 tidy_functions,
@@ -1062,7 +1062,7 @@
 php_info_print_table_start();
 php_info_print_table_header(2, Tidy support, enabled);
 php_info_print_table_row(2, libTidy Release, (char
*)tidyReleaseDate());
- php_info_print_table_row(2, Extension Version, 
PHP_TIDY_MODULE_VERSION

 ($Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $));
+ php_info_print_table_row(2, Extension Version, 
PHP_TIDY_MODULE_VERSION

 ($Id: tidy.c,v 1.120 2008/01/27 15:03:55 helly Exp $));
 php_info_print_table_end();

 DISPLAY_INI_ENTRIES(); 


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



[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c

2008-01-25 Thread Nuno Lopes
nlopess Fri Jan 25 20:30:36 2008 UTC

  Modified files:  
/php-src/ext/splphp_spl.c php_spl.h 
/php-src/ext/tidy   php_tidy.h tidy.c 
  Log:
  MFB: const keywording
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.120r2=1.121diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.120 php-src/ext/spl/php_spl.c:1.121
--- php-src/ext/spl/php_spl.c:1.120 Tue Jan 15 09:37:50 2008
+++ php-src/ext/spl/php_spl.c   Fri Jan 25 20:30:36 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_spl.c,v 1.120 2008/01/15 09:37:50 colder Exp $ */
+/* $Id: php_spl.c,v 1.121 2008/01/25 20:30:36 nlopess Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -46,13 +46,6 @@
 
 ZEND_DECLARE_MODULE_GLOBALS(spl)
 
-/* {{{ spl_functions_none
- */
-const zend_function_entry spl_functions_none[] = {
-   {NULL, NULL, NULL}
-};
-/* }}} */
-
 /* {{{ PHP_GINIT_FUNCTION
  */
 static PHP_GINIT_FUNCTION(spl)
@@ -788,7 +781,7 @@
 
 /* {{{ spl_module_entry
  */
-zend_module_entry spl_module_entry = {
+const zend_module_entry spl_module_entry = {
 #ifdef HAVE_SIMPLEXML
STANDARD_MODULE_HEADER_EX, NULL,
spl_deps,
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.24r2=1.25diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.24 php-src/ext/spl/php_spl.h:1.25
--- php-src/ext/spl/php_spl.h:1.24  Mon Dec 31 07:12:14 2007
+++ php-src/ext/spl/php_spl.h   Fri Jan 25 20:30:36 2008
@@ -28,7 +28,7 @@
 #define SPL_DEBUG(x)
 #endif
 
-extern zend_module_entry spl_module_entry;
+extern const zend_module_entry spl_module_entry;
 #define phpext_spl_ptr spl_module_entry
 
 #ifdef PHP_WIN32
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.36r2=1.37diff_format=u
Index: php-src/ext/tidy/php_tidy.h
diff -u php-src/ext/tidy/php_tidy.h:1.36 php-src/ext/tidy/php_tidy.h:1.37
--- php-src/ext/tidy/php_tidy.h:1.36Mon Dec 31 07:12:17 2007
+++ php-src/ext/tidy/php_tidy.h Fri Jan 25 20:30:36 2008
@@ -16,12 +16,12 @@
   +--+
 */
 
-/* $Id: php_tidy.h,v 1.36 2007/12/31 07:12:17 sebastian Exp $ */
+/* $Id: php_tidy.h,v 1.37 2008/01/25 20:30:36 nlopess Exp $ */
 
 #ifndef PHP_TIDY_H
 #define PHP_TIDY_H
 
-extern zend_module_entry tidy_module_entry;
+extern const zend_module_entry tidy_module_entry;
 #define phpext_tidy_ptr tidy_module_entry
 
 #define TIDY_METHOD_MAP(name, func_name, arg_types) \
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.118r2=1.119diff_format=u
Index: php-src/ext/tidy/tidy.c
diff -u php-src/ext/tidy/tidy.c:1.118 php-src/ext/tidy/tidy.c:1.119
--- php-src/ext/tidy/tidy.c:1.118   Mon Dec 31 07:12:17 2007
+++ php-src/ext/tidy/tidy.c Fri Jan 25 20:30:36 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: tidy.c,v 1.118 2007/12/31 07:12:17 sebastian Exp $ */
+/* $Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -359,7 +359,7 @@
 static zend_object_handlers tidy_object_handlers_doc;
 static zend_object_handlers tidy_object_handlers_node;
 
-zend_module_entry tidy_module_entry = {
+const zend_module_entry tidy_module_entry = {
STANDARD_MODULE_HEADER,
tidy,
tidy_functions,
@@ -1062,7 +1062,7 @@
php_info_print_table_start();
php_info_print_table_header(2, Tidy support, enabled);
php_info_print_table_row(2, libTidy Release, (char 
*)tidyReleaseDate());
-   php_info_print_table_row(2, Extension Version, 
PHP_TIDY_MODULE_VERSION  ($Id: tidy.c,v 1.118 2007/12/31 07:12:17 sebastian 
Exp $));
+   php_info_print_table_row(2, Extension Version, 
PHP_TIDY_MODULE_VERSION  ($Id: tidy.c,v 1.119 2008/01/25 20:30:36 nlopess Exp 
$));
php_info_print_table_end();
 
DISPLAY_INI_ENTRIES();

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



[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h spl_observer.c /ext/spl/tests observer_004.phpt observer_005.phpt

2007-01-19 Thread Marcus Boerger
helly   Fri Jan 19 23:23:08 2007 UTC

  Modified files:  
/php-src/ext/splphp_spl.c php_spl.h spl_observer.c 
/php-src/ext/spl/tests  observer_004.phpt observer_005.phpt 
  Log:
  - Make use of get_debug_info handler in SplObjectStorage
  http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.108r2=1.109diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.108 php-src/ext/spl/php_spl.c:1.109
--- php-src/ext/spl/php_spl.c:1.108 Fri Jan 12 22:28:05 2007
+++ php-src/ext/spl/php_spl.c   Fri Jan 19 23:23:08 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_spl.c,v 1.108 2007/01/12 22:28:05 helly Exp $ */
+/* $Id: php_spl.c,v 1.109 2007/01/19 23:23:08 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
#include config.h
@@ -593,16 +593,26 @@
 PHP_FUNCTION(spl_object_hash)
 {
zval *obj;
-   int len;
-   char *hash;
-   char md5str[33];
-   PHP_MD5_CTX context;
-   unsigned char digest[16];
+   char* md5str;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, o, obj) == 
FAILURE) {
return;
}
 
+   md5str = emalloc(33);
+   php_spl_object_hash(obj, md5str TSRMLS_CC);
+
+   RETVAL_STRING(md5str, 0);
+}
+/* }}} */
+
+PHPAPI void php_spl_object_hash(zval *obj, char *md5str TSRMLS_DC) /* {{{*/
+{
+   int len;
+   char *hash;
+   PHP_MD5_CTX context;
+   unsigned char digest[16];
+
len = spprintf(hash, 0, %p:%d, Z_OBJ_HT_P(obj), Z_OBJ_HANDLE_P(obj));

md5str[0] = '\0';
@@ -610,9 +620,9 @@
PHP_MD5Update(context, (unsigned char*)hash, len);
PHP_MD5Final(digest, context);
make_digest(md5str, digest);
-   RETVAL_STRING(md5str, 1);
efree(hash);
 }
+/* }}} */
 
 int spl_build_class_list_string(zval **entry, char **list TSRMLS_DC) /* {{{ */
 {
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.22r2=1.23diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.22 php-src/ext/spl/php_spl.h:1.23
--- php-src/ext/spl/php_spl.h:1.22  Mon Jan  1 09:29:29 2007
+++ php-src/ext/spl/php_spl.h   Fri Jan 19 23:23:08 2007
@@ -73,6 +73,8 @@
 PHP_FUNCTION(class_parents);
 PHP_FUNCTION(class_implements);
 
+PHPAPI void php_spl_object_hash(zval *obj, char* md5str TSRMLS_DC);
+
 #endif /* PHP_SPL_H */
 
 /*
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_observer.c?r1=1.15r2=1.16diff_format=u
Index: php-src/ext/spl/spl_observer.c
diff -u php-src/ext/spl/spl_observer.c:1.15 php-src/ext/spl/spl_observer.c:1.16
--- php-src/ext/spl/spl_observer.c:1.15 Mon Jan  1 09:29:29 2007
+++ php-src/ext/spl/spl_observer.c  Fri Jan 19 23:23:08 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_observer.c,v 1.15 2007/01/01 09:29:29 sebastian Exp $ */
+/* $Id: spl_observer.c,v 1.16 2007/01/19 23:23:08 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -116,6 +116,53 @@
 }
 /* }}} */
 
+static HashTable* spl_object_storage_debug_infos(zval *obj, int *is_temp 
TSRMLS_DC) /* {{{ */
+{
+   spl_SplObjectStorage *intern = 
(spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
+   HashTable *rv, *props;
+   HashPosition pos;
+   zval *tmp, *storage, **entry;
+   char md5str[33], *name;
+   int name_len;
+   zstr zname, zclass, zprop;
+
+   *is_temp = 1;
+
+   props = Z_OBJPROP_P(obj);
+   ALLOC_HASHTABLE(rv);
+   ZEND_INIT_SYMTABLE_EX(rv, zend_hash_num_elements(props) + 1, 0);
+   
+   zend_hash_copy(rv, props, (copy_ctor_func_t) zval_add_ref, (void *) 
tmp, sizeof(zval *));
+
+   MAKE_STD_ZVAL(storage);
+   array_init(storage);
+
+   zend_hash_internal_pointer_reset_ex(intern-storage, pos);
+   while (zend_hash_get_current_data_ex(intern-storage, (void **)entry, 
pos) == SUCCESS) {
+   php_spl_object_hash(*entry, md5str TSRMLS_CC);
+   zval_add_ref(entry);
+   add_assoc_zval_ex(storage, md5str, 33, *entry);
+   zend_hash_move_forward_ex(intern-storage, pos);
+   }
+
+   if (UG(unicode)) {
+   zclass.u = USTR_MAKE(SplObjectStorage);
+   zprop.u = USTR_MAKE(storage);
+   zend_u_mangle_property_name(zname, name_len, IS_UNICODE, 
zclass, sizeof(SplObjectStorage)-1, zprop, sizeof(storage)-1, 0);
+   zend_u_symtable_update(rv, IS_UNICODE, zname, name_len+1, 
storage, sizeof(zval *), NULL);
+   efree(zname.v);
+   efree(zclass.v);
+   efree(zprop.v);
+   } else {
+   zend_mangle_property_name(name, name_len, SplObjectStorage, 
sizeof(SplObjectStorage)-1, storage, sizeof(storage)-1, 0);
+   zend_symtable_update(rv, name, name_len+1, storage, 
sizeof(zval *), NULL);
+   efree(name);
+   }
+
+   return 

[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h

2006-12-20 Thread Marcus Boerger
helly   Wed Dec 20 22:11:14 2006 UTC

  Modified files:  
/php-src/ext/splphp_spl.c php_spl.h 
  Log:
  - More unicode
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.103r2=1.104diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.103 php-src/ext/spl/php_spl.c:1.104
--- php-src/ext/spl/php_spl.c:1.103 Tue Dec 19 22:31:26 2006
+++ php-src/ext/spl/php_spl.c   Wed Dec 20 22:11:14 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_spl.c,v 1.103 2006/12/19 22:31:26 helly Exp $ */
+/* $Id: php_spl.c,v 1.104 2006/12/20 22:11:14 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
#include config.h
@@ -55,8 +55,7 @@
  */
 static PHP_GINIT_FUNCTION(spl)
 {
-   spl_globals-autoload_extensions = NULL;
-   spl_globals-autoload_extensions_len = 0;
+   ZVAL_NULL(spl_globals-autoload_extensions);
spl_globals-autoload_functions  = NULL;
spl_globals-autoload_running= 0;
 }
@@ -205,7 +204,7 @@
 }
 /* }}} */
 
-int spl_autoload(const char *class_name, const char * lc_name, int 
class_name_len, const char * file_extension TSRMLS_DC) /* {{{ */
+int spl_autoload(const zstr class_name, const zstr lc_name, int 
class_name_len, const zstr file_extension TSRMLS_DC) /* {{{ */
 {
char *class_file;
int class_file_len;
@@ -216,7 +215,8 @@
zval err_mode;
int ret;
 
-   class_file_len = spprintf(class_file, 0, %s%s, lc_name, 
file_extension);
+   /* UTODO: Wewant the stream toacept a zstrfor opening */
+   class_file_len = spprintf(class_file, 0, %v%v, lc_name, 
file_extension);
 
ZVAL_LONG(err_mode, EG(error_reporting));
if (Z_LVAL(err_mode)) {
@@ -257,48 +257,65 @@
}
 
efree(class_file);
-   return zend_hash_exists(EG(class_table), 
(char*)lc_name, class_name_len+1);
+   return zend_u_hash_exists(EG(class_table), 
ZEND_STR_TYPE, lc_name, class_name_len+1);
}
}
efree(class_file);
return 0;
 } /* }}} */
 
-/* {{{ proto void spl_autoload(string class_name [, string file_extensions])
+/* {{{ proto void spl_autoload(string class_name [, string file_extensions]) U
  Default implementation for __autoload() */
 PHP_FUNCTION(spl_autoload)
 {
-   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;
+   zstr class_name, lc_name;
+   zstr file_exts = Z_UNIVAL(SPL_G(autoload_extensions));
+   int class_name_len, file_exts_len = 
Z_UNILEN(SPL_G(autoload_extensions)), found = 0;
+   int unicode = UG(unicode);
+   zstr copy, pos1, pos2;
zval **original_return_value = EG(return_value_ptr_ptr);
zend_op **original_opline_ptr = EG(opline_ptr);
zend_op_array *original_active_op_array = EG(active_op_array);
zend_function_state *original_function_state_ptr = 
EG(function_state_ptr);

-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|s, 
class_name, class_name_len, file_exts, file_exts_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, x|x, 
class_name, class_name_len, file_exts, file_exts_len) == FAILURE) {
RETURN_FALSE;
}
 
-   copy = pos1 = estrndup(file_exts, file_exts_len);
-   lc_name = zend_str_tolower_dup(class_name, class_name_len);
-   while(pos1  *pos1  !EG(exception)) {
+   copy = pos1 = zend_zstrndup(ZEND_STR_TYPE, file_exts, file_exts_len);
+   lc_name = zend_u_str_tolower_dup(ZEND_STR_TYPE, class_name, 
class_name_len);
+   while(pos1.v  (unicode ? *pos1.u : *pos1.s)  !EG(exception)) {
EG(return_value_ptr_ptr) = original_return_value;
EG(opline_ptr) = original_opline_ptr;
EG(active_op_array) = original_active_op_array;
EG(function_state_ptr) = original_function_state_ptr;
-   pos2 = strchr(pos1, ',');
-   if (pos2) *pos2 = '\0';
+   if (unicode) {
+   pos2.u = u_strchr(pos1.u, ',');
+   if (pos2.u) *pos2.u = '\0';
+   } else {
+   pos2.s = strchr(pos1.s, ',');
+   if (pos2.s) *pos2.s = '\0';
+   }
if (spl_autoload(class_name, lc_name, class_name_len, pos1 
TSRMLS_CC)) {
found = 1;
break; /* loaded */
}
-   pos1 = pos2 ? pos2 + 1 : NULL;
+   if (!pos2.v) {
+   pos1.v = NULL;
+   } else if (unicode) {
+   pos1.u = pos2.u + 1;
+   } else{
+   pos1.s = pos2.s + 1;
+   }
}
-   

[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h

2006-11-04 Thread Marcus Boerger
helly   Sat Nov  4 20:22:29 2006 UTC

  Modified files:  
/php-src/ext/splphp_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.98r2=1.99diff_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.19r2=1.20diff_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



[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/spl/tests spl_autoload_009.phpt

2006-10-31 Thread Marcus Boerger
helly   Tue Oct 31 23:18:00 2006 UTC

  Added files: 
/php-src/ext/spl/tests  spl_autoload_009.phpt 

  Modified files:  
/php-src/ext/splphp_spl.c php_spl.h 
  Log:
  - Fixed Bug #39313 spl_autoload triggers Fatal error
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.96r2=1.97diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.96 php-src/ext/spl/php_spl.c:1.97
--- php-src/ext/spl/php_spl.c:1.96  Thu Aug  3 14:53:51 2006
+++ php-src/ext/spl/php_spl.c   Tue Oct 31 23:18:00 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_spl.c,v 1.96 2006/08/03 14:53:51 iliaa Exp $ */
+/* $Id: php_spl.c,v 1.97 2006/10/31 23:18:00 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
#include config.h
@@ -57,6 +57,7 @@
 {
spl_globals-autoload_extensions = NULL;
spl_globals-autoload_functions  = NULL;
+   spl_globals-autoload_running= 0;
 }
 /* }}} */
 
@@ -303,7 +304,7 @@
EG(active_op_array) = original_active_op_array;
EG(function_state_ptr) = original_function_state_ptr;
 
-   if (!found) {
+   if (!found  !SPL_G(autoload_running)) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, 
Class %s could not be loaded, class_name);
}
 } /* }}} */
@@ -360,6 +361,8 @@
}
 
if (SPL_G(autoload_functions)) {
+   int l_autoload_running = SPL_G(autoload_running);
+   SPL_G(autoload_running) = 1;
class_name_type = Z_TYPE_P(class_name);
class_name_len = Z_UNILEN_P(class_name);
lc_name = zend_u_str_tolower_dup(class_name_type, 
Z_UNIVAL_P(class_name), class_name_len);
@@ -378,6 +381,7 @@
zend_hash_move_forward_ex(SPL_G(autoload_functions), 
function_pos);
}
efree(lc_name.v);
+   SPL_G(autoload_running) = l_autoload_running;
} else {
/* do not use or overwrite EG(autoload_func) here */
zend_call_method_with_1_params(NULL, NULL, NULL, 
spl_autoload, NULL, class_name);
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.18r2=1.19diff_format=u
Index: php-src/ext/spl/php_spl.h
diff -u php-src/ext/spl/php_spl.h:1.18 php-src/ext/spl/php_spl.h:1.19
--- php-src/ext/spl/php_spl.h:1.18  Sun Jan  1 13:09:54 2006
+++ php-src/ext/spl/php_spl.h   Tue Oct 31 23:18:00 2006
@@ -58,6 +58,7 @@
 ZEND_BEGIN_MODULE_GLOBALS(spl)
char *   autoload_extensions;
HashTable *  autoload_functions;
+   int  autoload_running;
 ZEND_END_MODULE_GLOBALS(spl)
 
 #ifdef ZTS

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/spl_autoload_009.phpt?view=markuprev=1.1
Index: php-src/ext/spl/tests/spl_autoload_009.phpt
+++ php-src/ext/spl/tests/spl_autoload_009.phpt
--TEST--
SPL: spl_autoload() and friends
--SKIPIF--
?php if (!extension_loaded(spl)) print skip; ?
--INI--
include_path=.
--FILE--
?php

function my_autoload($name)
{
require $name . '.class.inc';
var_dump(class_exists($name));
}

spl_autoload_register(spl_autoload);
spl_autoload_register(my_autoload);

$obj = new testclass;

?
===DONE===
?php exit(0); ?
--EXPECTF--
%stestclass.inc
%stestclass.class.inc
bool(true)
===DONE===

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



[PHP-CVS] cvs: php-src /ext/spl php_spl.c php_spl.h /ext/spl/tests spl_autoload_001.phpt testclass testclass.class.inc testclass.inc testclass.php.inc

2005-03-01 Thread Marcus Boerger
helly   Tue Mar  1 20:14:41 2005 EDT

  Added files: 
/php-src/ext/spl/tests  spl_autoload_001.phpt testclass 
testclass.class.inc testclass.inc 
testclass.php.inc 

  Modified files:  
/php-src/ext/splphp_spl.c php_spl.h 
  Log:
  - Add new functions
  
  http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.40r2=1.41ty=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.40 php-src/ext/spl/php_spl.c:1.41
--- php-src/ext/spl/php_spl.c:1.40  Sun Feb 13 13:30:26 2005
+++ php-src/ext/spl/php_spl.c   Tue Mar  1 20:14:40 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_spl.c,v 1.40 2005/02/13 18:30:26 helly Exp $ */
+/* $Id: php_spl.c,v 1.41 2005/03/02 01:14:40 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
#include config.h
@@ -34,6 +34,8 @@
 #include spl_sxe.h
 #include spl_exceptions.h
 #include spl_observer.h
+#include zend_exceptions.h
+#include zend_interfaces.h
 
 #ifdef COMPILE_DL_SPL
 ZEND_GET_MODULE(spl)
@@ -52,6 +54,8 @@
  */
 static void spl_init_globals(zend_spl_globals *spl_globals)
 {
+   spl_globals-autoload_extensions = .inc,.inc.php;
+   spl_globals-autoload_functions  = NULL;
 }
 /* }}} */
 
@@ -136,6 +140,201 @@
 }
 /* }}} */
 
+int spl_autoload(const char *class_name, const char * lc_name, int 
class_name_len, const char * file_extension TSRMLS_DC) /* {{{ */
+{
+   char *class_file;
+   int class_file_len;
+   int dummy = 1;
+   zend_file_handle file_handle;
+   zend_op_array *new_op_array;
+   zval *result = NULL;
+   
+   ;
+   
+   class_file_len = spprintf(class_file, 0, %s%s, lc_name, 
file_extension);
+
+   if (zend_stream_open(class_file, file_handle TSRMLS_CC) == SUCCESS) {
+   if (!file_handle.opened_path) {
+   file_handle.opened_path = estrndup(class_file, 
class_file_len);
+   }
+   if (zend_hash_add(EG(included_files), file_handle.opened_path, 
strlen(file_handle.opened_path)+1, (void *)dummy, sizeof(int), NULL)==SUCCESS) 
{
+   new_op_array = zend_compile_file(file_handle, 
ZEND_REQUIRE TSRMLS_CC);
+   zend_destroy_file_handle(file_handle TSRMLS_CC);
+   } else {
+   new_op_array = NULL;
+   zend_file_handle_dtor(file_handle);
+   }
+   if (new_op_array) {
+   EG(return_value_ptr_ptr) = result;
+   EG(active_op_array) = new_op_array;
+   
+   zend_execute(new_op_array TSRMLS_CC);
+   
+   destroy_op_array(new_op_array TSRMLS_CC);
+   efree(new_op_array);
+   if (!EG(exception)) {
+   if (EG(return_value_ptr_ptr)) {
+   zval_ptr_dtor(EG(return_value_ptr_ptr));
+   }
+   }
+
+   efree(class_file);
+   return zend_hash_exists(EG(class_table), 
(char*)lc_name, class_name_len+1);
+   }
+   }
+   efree(class_file);
+   return 0;
+} /* }}} */
+
+/* {{{ void spl_autoload(string class_name [, string file_extensions])
+ 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 *copy, *pos1, *pos2;
+   zval **original_return_value = EG(return_value_ptr_ptr);
+   zend_op **original_opline_ptr = EG(opline_ptr);
+   zend_op_array *original_active_op_array = EG(active_op_array);
+   zend_function_state *original_function_state_ptr = 
EG(function_state_ptr);
+   zval err_mode;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|s, 
class_name, class_name_len, file_exts, file_exts_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   ZVAL_LONG(err_mode, EG(error_reporting));
+   php_alter_ini_entry(error_reporting, sizeof(error_reporting), 0, 
1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); 
+
+   copy = pos1 = estrdup(ZEND_NUM_ARGS()  1 ? file_exts : 
SPL_G(autoload_extensions));
+   lc_name = zend_str_tolower_dup(class_name, class_name_len);
+   while(pos1  *pos1  !EG(exception)) {
+   EG(return_value_ptr_ptr) = original_return_value;
+   EG(opline_ptr) = original_opline_ptr;
+   EG(active_op_array) = original_active_op_array;
+   EG(function_state_ptr) = original_function_state_ptr;
+   pos2 = strchr(pos1, ',');
+   if (pos2) *pos2 = '\0';
+   if (spl_autoload(class_name, lc_name, class_name_len, pos1 
TSRMLS_CC)) {
+   found = 1;
+   break; /*