[PHP-CVS] cvs: php-src(PHP_5_2) /ext/spl spl_iterators.c spl_iterators.h /ext/spl/tests iterator_041.phpt iterator_041a.phpt iterator_041b.phpt
helly Sat May 20 21:01:42 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/spl/tests iterator_041.phpt iterator_041a.phpt iterator_041b.phpt Modified files: /php-src/ext/splspl_iterators.c spl_iterators.h Log: - MFH Sync with head fixes part of an issue with iterator_(to_array|count) http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.73.2.30.2.7&r2=1.73.2.30.2.8&diff_format=u Index: php-src/ext/spl/spl_iterators.c diff -u php-src/ext/spl/spl_iterators.c:1.73.2.30.2.7 php-src/ext/spl/spl_iterators.c:1.73.2.30.2.8 --- php-src/ext/spl/spl_iterators.c:1.73.2.30.2.7 Thu May 18 21:48:33 2006 +++ php-src/ext/spl/spl_iterators.c Sat May 20 21:01:42 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_iterators.c,v 1.73.2.30.2.7 2006/05/18 21:48:33 helly Exp $ */ +/* $Id: spl_iterators.c,v 1.73.2.30.2.8 2006/05/20 21:01:42 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -2372,63 +2372,100 @@ {NULL, NULL, NULL} }; -/* {{{ proto array iterator_to_array(Traversable it) - Copy the iterator into an array */ -PHP_FUNCTION(iterator_to_array) +PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser TSRMLS_DC) { - zval *obj, **data; zend_object_iterator *iter; - char *str_key; - uintstr_key_len; - ulong int_key; - int key_type; + zend_class_entry *ce = Z_OBJCE_P(obj); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, zend_ce_traversable) == FAILURE) { - RETURN_FALSE; + iter = ce->get_iterator(ce, obj, 0 TSRMLS_CC); + + if (EG(exception)) { + goto done; } - - array_init(return_value); - - iter = Z_OBJCE_P(obj)->get_iterator(Z_OBJCE_P(obj), obj, 0 TSRMLS_CC); if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); + if (EG(exception)) { + goto done; + } } - if (EG(exception)) { - return; - } + while (iter->funcs->valid(iter TSRMLS_CC) == SUCCESS) { - iter->funcs->get_current_data(iter, &data TSRMLS_CC); if (EG(exception)) { - return; + goto done; } - (*data)->refcount++; - if (iter->funcs->get_current_key) { - key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); - if (EG(exception)) { - return; - } - switch(key_type) { - case HASH_KEY_IS_STRING: - add_assoc_zval_ex(return_value, str_key, str_key_len, *data); - efree(str_key); - break; - case HASH_KEY_IS_LONG: - add_index_zval(return_value, int_key, *data); - break; - } - } else { - add_next_index_zval(return_value, *data); + if (apply_func(iter, puser TSRMLS_CC) == ZEND_HASH_APPLY_STOP || EG(exception)) { + goto done; } iter->funcs->move_forward(iter TSRMLS_CC); if (EG(exception)) { - return; + goto done; } } + +done: iter->funcs->dtor(iter TSRMLS_CC); + return EG(exception) ? FAILURE : SUCCESS; +} +/* }}} */ + +static int spl_iterator_to_array_apply(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */ +{ + zval**data, *return_value = (zval*)puser; + char*str_key; + uintstr_key_len; + ulong int_key; + int key_type; + + iter->funcs->get_current_data(iter, &data TSRMLS_CC); if (EG(exception)) { - return; + return ZEND_HASH_APPLY_STOP; + } + if (iter->funcs->get_current_key) { + key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); + if (EG(exception)) { + return ZEND_HASH_APPLY_STOP; + } + (*data)->refcount++; + switch(key_type) { + case HASH_KEY_IS_STRING: + add_assoc_zval_ex(return_value, str_key, str_key_len, *data); +
[PHP-CVS] cvs: php-src /ext/spl spl_iterators.c
helly Sat May 20 20:46:11 2006 UTC Modified files: /php-src/ext/splspl_iterators.c Log: - No need to fetch ce twice http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.130&r2=1.131&diff_format=u Index: php-src/ext/spl/spl_iterators.c diff -u php-src/ext/spl/spl_iterators.c:1.130 php-src/ext/spl/spl_iterators.c:1.131 --- php-src/ext/spl/spl_iterators.c:1.130 Sat May 20 18:48:43 2006 +++ php-src/ext/spl/spl_iterators.c Sat May 20 20:46:11 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_iterators.c,v 1.130 2006/05/20 18:48:43 helly Exp $ */ +/* $Id: spl_iterators.c,v 1.131 2006/05/20 20:46:11 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -2404,8 +2404,9 @@ PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser TSRMLS_DC) { zend_object_iterator *iter; + zend_class_entry *ce = Z_OBJCE_P(obj); - iter = Z_OBJCE_P(obj)->get_iterator(Z_OBJCE_P(obj), obj, 0 TSRMLS_CC); + iter = ce->get_iterator(ce, obj, 0 TSRMLS_CC); if (EG(exception)) { goto 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/tests iterator_041.phpt iterator_041a.phpt iterator_041b.phpt
helly Sat May 20 20:38:28 2006 UTC Added files: /php-src/ext/spl/tests iterator_041a.phpt iterator_041b.phpt Modified files: /php-src/ext/spl/tests iterator_041.phpt Log: - Split up the test in different problem categories http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/iterator_041.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/spl/tests/iterator_041.phpt diff -u php-src/ext/spl/tests/iterator_041.phpt:1.2 php-src/ext/spl/tests/iterator_041.phpt:1.3 --- php-src/ext/spl/tests/iterator_041.phpt:1.2 Sat May 20 19:01:22 2006 +++ php-src/ext/spl/tests/iterator_041.phpt Sat May 20 20:38:28 2006 @@ -8,6 +8,7 @@ class MyArrayIterator extends ArrayIterator { static protected $fail = 0; + public $state; static function fail($state, $method) { @@ -19,6 +20,7 @@ function __construct() { + $this->state = MyArrayIterator::$fail; self::fail(0, __FUNCTION__); parent::__construct(array(1, 2)); self::fail(1, __FUNCTION__); @@ -56,10 +58,10 @@ function __destruct() { - self::fail(7, __FUNCTION__); +// self::fail(7, __FUNCTION__); } - static function test($func) + static function test($func, $skip = null) { echo "===$func===\n"; self::$fail = 0; @@ -72,29 +74,35 @@ } catch (Exception $e) { - var_dump($e->getMessage()); + echo $e->getMessage() . "\n"; + } + if (isset($skip[self::$fail])) + { + self::$fail = $skip[self::$fail]; + } + else + { + self::$fail++; } - self::$fail++; } } } MyArrayIterator::test('iterator_to_array'); -MyArrayIterator::test('iterator_count'); +MyArrayIterator::test('iterator_count', array(3 => 6)); ?> ===DONE=== --EXPECT-- ===iterator_to_array=== -string(22) "State 0: __construct()" -string(22) "State 1: __construct()" -string(17) "State 2: rewind()" -string(16) "State 3: valid()" -string(18) "State 4: current()" -string(14) "State 5: key()" -string(15) "State 6: next()" -string(21) "State 7: __destruct()" +State 0: __construct() +State 1: __construct() +State 2: rewind() +State 3: valid() +State 4: current() +State 5: key() +State 6: next() array(2) { [0]=> int(1) @@ -102,11 +110,10 @@ int(2) } ===iterator_count=== -string(22) "State 0: __construct()" -string(22) "State 1: __construct()" -string(17) "State 2: rewind()" -string(16) "State 3: valid()" -string(15) "State 6: next()" -string(21) "State 7: __destruct()" +State 0: __construct() +State 1: __construct() +State 2: rewind() +State 3: valid() +State 6: next() int(2) ===DONE=== http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/iterator_041a.phpt?view=markup&rev=1.1 Index: php-src/ext/spl/tests/iterator_041a.phpt +++ php-src/ext/spl/tests/iterator_041a.phpt --TEST-- SPL: iterator_to_array() and exceptions from destruct --SKIPIF-- --FILE-- state = MyArrayIterator::$fail; self::fail(0, __FUNCTION__); parent::__construct(array(1, 2)); self::fail(1, __FUNCTION__); } function rewind() { self::fail(2, __FUNCTION__); return parent::rewind(); } function valid() { self::fail(3, __FUNCTION__); return parent::valid(); } function current() { self::fail(4, __FUNCTION__); return parent::current(); } function key() { self::fail(5, __FUNCTION__); return parent::key(); } function next() { self::fail(6, __FUNCTION__); return parent::next(); } function __destruct() { self::fail(7, __FUNCTION__); } static function test($func, $skip = null) { echo "===$func===\n"; self::$fail = 7; while(self::$fail < 10) { try { var_dump($func(new MyArrayIterator())); break; } catch (Exception $e) { echo $e->getMessage() . "\n"; } if (isset($skip[self::$fail])) { self::$fail = $skip[self::$fail];
[PHP-CVS] cvs: php-src /ext/spl spl_array.c
helly Sat May 20 19:47:18 2006 UTC Modified files: /php-src/ext/splspl_array.c Log: - Micro optimization http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_array.c?r1=1.110&r2=1.111&diff_format=u Index: php-src/ext/spl/spl_array.c diff -u php-src/ext/spl/spl_array.c:1.110 php-src/ext/spl/spl_array.c:1.111 --- php-src/ext/spl/spl_array.c:1.110 Fri Apr 7 22:53:34 2006 +++ php-src/ext/spl/spl_array.c Sat May 20 19:47:18 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_array.c,v 1.110 2006/04/07 22:53:34 tony2001 Exp $ */ +/* $Id: spl_array.c,v 1.111 2006/05/20 19:47:18 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -260,7 +260,7 @@ /* We cannot get the pointer pointer so we don't allow it here for now if (check_inherited && intern->fptr_offset_get) { - return zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", NULL, offset); + return zend_call_method_with_1_params(&object, intern->std.ce, &intern->fptr_offset_get, "offsetGet", NULL, offset); }*/ if (!offset) { @@ -305,7 +305,7 @@ if (intern->fptr_offset_get) { zval *rv; SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", &rv, offset); + zend_call_method_with_1_params(&object, intern->std.ce, &intern->fptr_offset_get, "offsetGet", &rv, offset); zval_ptr_dtor(&offset); if (rv) { zval_ptr_dtor(&intern->retval); @@ -335,7 +335,7 @@ } else { SEPARATE_ARG_IF_REF(offset); } - zend_call_method_with_2_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_set, "offsetSet", NULL, offset, value); + zend_call_method_with_2_params(&object, intern->std.ce, &intern->fptr_offset_set, "offsetSet", NULL, offset, value); zval_ptr_dtor(&offset); return; } @@ -390,7 +390,7 @@ if (check_inherited && intern->fptr_offset_del) { SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_del, "offsetUnset", NULL, offset); + zend_call_method_with_1_params(&object, intern->std.ce, &intern->fptr_offset_del, "offsetUnset", NULL, offset); zval_ptr_dtor(&offset); return; } @@ -441,7 +441,7 @@ if (check_inherited && intern->fptr_offset_has) { SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_has, "offsetExists", &rv, offset); + zend_call_method_with_1_params(&object, intern->std.ce, &intern->fptr_offset_has, "offsetExists", &rv, offset); zval_ptr_dtor(&offset); if (rv && zend_is_true(rv)) { zval_ptr_dtor(&rv); @@ -527,7 +527,7 @@ } if (Z_TYPE_P(intern->array) == IS_OBJECT) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Cannot append properties to objects, use %v::offsetSet() instead", Z_OBJCE_P(object)->name); + php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Cannot append properties to objects, use %v::offsetSet() instead", intern->std.ce->name); return; } @@ -920,7 +920,7 @@ if ((handler != std_object_handlers.get_properties && handler != spl_array_get_properties) || !spl_array_get_hash_table(intern, 0 TSRMLS_CC)) { php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Overloaded object of type %s is not compatible with %s", Z_OBJCE_P(array)->name, intern->std.ce->name); + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Overloaded object of type %s is not compatible with %s", intern->std.ce->name, intern->std.ce->name); return; } } @@ -1350,11 +1350,11 @@ return; } - if (Z_TYPE_PP(entry) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(entry), Z_OBJCE_P(getThis()) TSRMLS_CC)) { + if (Z_TYPE_PP(entry) == IS_OBJECT && instanceof_function(Z_OBJCE_PP(entry), intern->std.ce TSRMLS_CC)) { RETURN_ZVAL(*entry, 0, 0); } - spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0, *entry TSRMLS_CC); + spl_instantiate_arg_ex1(intern->std.ce, &return_value, 0, *entry TSRMLS_CC); } /* }}} */ -- PHP CVS Mailing List (http://www.php
[PHP-CVS] cvs: php-src /ext/spl/tests iterator_041.phpt
helly Sat May 20 19:01:22 2006 UTC Modified files: /php-src/ext/spl/tests iterator_041.phpt Log: - Update test http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/iterator_041.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/spl/tests/iterator_041.phpt diff -u php-src/ext/spl/tests/iterator_041.phpt:1.1 php-src/ext/spl/tests/iterator_041.phpt:1.2 --- php-src/ext/spl/tests/iterator_041.phpt:1.1 Sat May 20 13:23:00 2006 +++ php-src/ext/spl/tests/iterator_041.phpt Sat May 20 19:01:22 2006 @@ -36,16 +36,16 @@ return parent::valid(); } - function key() + function current() { self::fail(4, __FUNCTION__); - return parent::key(); + return parent::current(); } - function current() + function key() { self::fail(5, __FUNCTION__); - return parent::current(); + return parent::key(); } function next() @@ -59,15 +59,15 @@ self::fail(7, __FUNCTION__); } - static function test() + static function test($func) { + echo "===$func===\n"; self::$fail = 0; while(self::$fail < 10) { - echo '===' . self::$fail . "===\n"; try { - var_dump(iterator_to_array(new MyArrayIterator())); + var_dump($func(new MyArrayIterator())); break; } catch (Exception $e) @@ -76,73 +76,37 @@ } self::$fail++; } - - self::$fail = 0; - while(self::$fail < 10) - { - echo '===' . self::$fail . "===\n"; - try - { - var_dump(iterator_count(new MyArrayIterator())); - break; - } - catch (Exception $e) - { - var_dump($e->getMessage()); - } - if (self::$fail == 3) - { - self::$fail = 6; - } - else - { - self::$fail++; - } - } } } -MyArrayIterator::test(); +MyArrayIterator::test('iterator_to_array'); +MyArrayIterator::test('iterator_count'); ?> ===DONE=== --EXPECT-- -===0=== +===iterator_to_array=== string(22) "State 0: __construct()" -===1=== string(22) "State 1: __construct()" -===2=== string(17) "State 2: rewind()" -===3=== string(16) "State 3: valid()" -===4=== -string(14) "State 4: key()" -===5=== -string(18) "State 5: current()" -===6=== +string(18) "State 4: current()" +string(14) "State 5: key()" string(15) "State 6: next()" -===7=== string(21) "State 7: __destruct()" -===8=== array(2) { [0]=> int(1) [1]=> int(2) } -===0=== +===iterator_count=== string(22) "State 0: __construct()" -===1=== string(22) "State 1: __construct()" -===2=== string(17) "State 2: rewind()" -===3=== string(16) "State 3: valid()" -===4=== string(15) "State 6: next()" -===7=== string(21) "State 7: __destruct()" -===8=== int(2) ===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 spl_iterators.c
helly Sat May 20 18:48:43 2006 UTC Modified files: /php-src/ext/splspl_iterators.c Log: - No need to keep object alive, iterator api is taking care of that already http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.129&r2=1.130&diff_format=u Index: php-src/ext/spl/spl_iterators.c diff -u php-src/ext/spl/spl_iterators.c:1.129 php-src/ext/spl/spl_iterators.c:1.130 --- php-src/ext/spl/spl_iterators.c:1.129 Sat May 20 13:23:00 2006 +++ php-src/ext/spl/spl_iterators.c Sat May 20 18:48:43 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_iterators.c,v 1.129 2006/05/20 13:23:00 helly Exp $ */ +/* $Id: spl_iterators.c,v 1.130 2006/05/20 18:48:43 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -2405,7 +2405,6 @@ { zend_object_iterator *iter; - obj->refcount++; iter = Z_OBJCE_P(obj)->get_iterator(Z_OBJCE_P(obj), obj, 0 TSRMLS_CC); if (EG(exception)) { @@ -2434,9 +2433,6 @@ done: iter->funcs->dtor(iter TSRMLS_CC); - if (obj->refcount > 0 && !EG(exception)) { - zval_ptr_dtor(&obj); - } return EG(exception) ? FAILURE : SUCCESS; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/oci8 oci8_lob.c
tony2001Sat May 20 13:46:59 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/oci8 oci8_lob.c Log: MFH: attempt to fix OCILobRead2() related problems http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/oci8_lob.c?r1=1.7.2.6&r2=1.7.2.6.2.1&diff_format=u Index: php-src/ext/oci8/oci8_lob.c diff -u php-src/ext/oci8/oci8_lob.c:1.7.2.6 php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.1 --- php-src/ext/oci8/oci8_lob.c:1.7.2.6 Wed Apr 5 14:06:00 2006 +++ php-src/ext/oci8/oci8_lob.c Sat May 20 13:46:59 2006 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: oci8_lob.c,v 1.7.2.6 2006/04/05 14:06:00 tony2001 Exp $ */ +/* $Id: oci8_lob.c,v 1.7.2.6.2.1 2006/05/20 13:46:59 tony2001 Exp $ */ @@ -150,11 +150,16 @@ { php_oci_connection *connection = descriptor->connection; ub4 length = 0; +#if defined(HAVE_OCI_LOB_READ2) + oraub8 bytes_read, bytes_total = 0, offset = 0; + oraub8 requested_len = read_length; /* this is by default */ + oraub8 chars_read = 0; +#else int bytes_read, bytes_total = 0, offset = 0; int requested_len = read_length; /* this is by default */ -#if defined(HAVE_OCI_LOB_READ2) - int chars_read = 0, is_clob = 0; + int chars_read = 0; #endif + int is_clob = 0; *data_len = 0; *data = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/oci8 oci8_lob.c
tony2001Sat May 20 13:46:41 2006 UTC Modified files: /php-src/ext/oci8 oci8_lob.c Log: attempt to fix OCILobRead2() related problems http://cvs.php.net/viewcvs.cgi/php-src/ext/oci8/oci8_lob.c?r1=1.12&r2=1.13&diff_format=u Index: php-src/ext/oci8/oci8_lob.c diff -u php-src/ext/oci8/oci8_lob.c:1.12 php-src/ext/oci8/oci8_lob.c:1.13 --- php-src/ext/oci8/oci8_lob.c:1.12Wed Apr 5 14:07:16 2006 +++ php-src/ext/oci8/oci8_lob.c Sat May 20 13:46:41 2006 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: oci8_lob.c,v 1.12 2006/04/05 14:07:16 tony2001 Exp $ */ +/* $Id: oci8_lob.c,v 1.13 2006/05/20 13:46:41 tony2001 Exp $ */ @@ -150,11 +150,16 @@ { php_oci_connection *connection = descriptor->connection; ub4 length = 0; +#if defined(HAVE_OCI_LOB_READ2) + oraub8 bytes_read, bytes_total = 0, offset = 0; + oraub8 requested_len = read_length; /* this is by default */ + oraub8 chars_read = 0; +#else int bytes_read, bytes_total = 0, offset = 0; int requested_len = read_length; /* this is by default */ -#if defined(HAVE_OCI_LOB_READ2) - int chars_read = 0, is_clob = 0; + int chars_read = 0; #endif + int is_clob = 0; *data_len = 0; *data = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/spl spl_iterators.c spl_iterators.h /ext/spl/tests iterator_041.phpt
helly Sat May 20 13:23:00 2006 UTC Added files: /php-src/ext/spl/tests iterator_041.phpt Modified files: /php-src/ext/splspl_iterators.c spl_iterators.h Log: - Provide a generic c-level iterator apply function - Base iterator_to_array() and iterator_count() on it - Add a testcase # Somehow there is an issue with exceptions in __destruct() here http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.128&r2=1.129&diff_format=u Index: php-src/ext/spl/spl_iterators.c diff -u php-src/ext/spl/spl_iterators.c:1.128 php-src/ext/spl/spl_iterators.c:1.129 --- php-src/ext/spl/spl_iterators.c:1.128 Thu May 18 21:41:37 2006 +++ php-src/ext/spl/spl_iterators.c Sat May 20 13:23:00 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_iterators.c,v 1.128 2006/05/18 21:41:37 helly Exp $ */ +/* $Id: spl_iterators.c,v 1.129 2006/05/20 13:23:00 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -2401,67 +2401,107 @@ {NULL, NULL, NULL} }; -/* {{{ proto array iterator_to_array(Traversable it) - Copy the iterator into an array */ -PHP_FUNCTION(iterator_to_array) +PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser TSRMLS_DC) { - zval *obj, **data; zend_object_iterator *iter; - zstrstr_key; - uintstr_key_len; - ulong int_key; - int key_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, zend_ce_traversable) == FAILURE) { - RETURN_FALSE; - } - - array_init(return_value); - + obj->refcount++; iter = Z_OBJCE_P(obj)->get_iterator(Z_OBJCE_P(obj), obj, 0 TSRMLS_CC); + if (EG(exception)) { + goto done; + } + if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); + if (EG(exception)) { + goto done; + } } - if (EG(exception)) { - return; - } + while (iter->funcs->valid(iter TSRMLS_CC) == SUCCESS) { - iter->funcs->get_current_data(iter, &data TSRMLS_CC); if (EG(exception)) { - return; + goto done; } - (*data)->refcount++; - if (iter->funcs->get_current_key) { - key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); - if (EG(exception)) { - return; - } - switch(key_type) { - case HASH_KEY_IS_STRING: - add_assoc_zval_ex(return_value, str_key.s, str_key_len, *data); - efree(str_key.s); - break; - case HASH_KEY_IS_UNICODE: - add_u_assoc_zval_ex(return_value, IS_UNICODE, str_key, str_key_len, *data); - efree(str_key.u); - break; - case HASH_KEY_IS_LONG: - add_index_zval(return_value, int_key, *data); - break; - } - } else { - add_next_index_zval(return_value, *data); + if (apply_func(iter, puser TSRMLS_CC) == ZEND_HASH_APPLY_STOP || EG(exception)) { + goto done; } iter->funcs->move_forward(iter TSRMLS_CC); if (EG(exception)) { - return; + goto done; } } + +done: iter->funcs->dtor(iter TSRMLS_CC); + if (obj->refcount > 0 && !EG(exception)) { + zval_ptr_dtor(&obj); + } + return EG(exception) ? FAILURE : SUCCESS; +} +/* }}} */ + +static int spl_iterator_to_array_apply(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */ +{ + zval**data, *return_value = (zval*)puser; + zstrstr_key; + uintstr_key_len; + ulong int_key; + int key_type; + + iter->funcs->get_current_data(iter, &data TSRMLS_CC); if (EG(exception)) { - return; + return ZEND_HASH_APPLY_STOP; } + if (iter->funcs->get_current_key) { + key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); + if (EG(exception)) { + re
Re: [PHP-CVS] cvs: php-src(PHP_4_4) /ext/wddx wddx.c
Hello Antony, ok, i checked the code in full length and all is fine indeed :-) best regards marcus Saturday, May 20, 2006, 3:07:57 PM, you wrote: > Hello Marcus. > What I did is basically backported this fix by Jani: > http://cvs.php.net/viewcvs.cgi/php-src/ext/wddx/wddx.c?r1=1.119.2.1&r2=1.119.2.2 > If you feel it's wrong - please fix it, though it works fine for me. > On 20.05.2006 02:35, Marcus Boerger wrote: >> Hello Antony, >> >>see inplace comments below >> >> best regards >> marcus >> >> Friday, May 19, 2006, 12:37:32 PM, you wrote: >> >>> tony2001Fri May 19 10:37:32 2006 UTC >> >>> Modified files: (Branch: PHP_4_4) >>> /php-src/ext/wddx wddx.c >>> Log: >>> MFH fix for #34306 (wddx_serialize_value() crashes with long array keys) >>> >>> >>> http://cvs.php.net/viewcvs.cgi/php-src/ext/wddx/wddx.c?r1=1.96.2.6.2.4&r2=1.96.2.6.2.5&diff_format=u >>> Index: php-src/ext/wddx/wddx.c >>> diff -u php-src/ext/wddx/wddx.c:1.96.2.6.2.4 >>> php-src/ext/wddx/wddx.c:1.96.2.6.2.5 >>> --- php-src/ext/wddx/wddx.c:1.96.2.6.2.4Sun Apr 23 16:02:37 2006 >>> +++ php-src/ext/wddx/wddx.c Fri May 19 10:37:32 2006 >>> @@ -16,7 +16,7 @@ >>> +--+ >>> */ >>> >>> -/* $Id: wddx.c,v 1.96.2.6.2.4 2006/04/23 16:02:37 iliaa Exp $ */ >>> +/* $Id: wddx.c,v 1.96.2.6.2.5 2006/05/19 10:37:32 tony2001 Exp $ */ >>> >>> #ifdef HAVE_CONFIG_H >>> #include "config.h" >>> @@ -432,7 +432,7 @@ >>> tmp = *var; >>> zval_copy_ctor(&tmp); >>> convert_to_string(&tmp); >>> - sprintf(tmp_buf, WDDX_NUMBER, Z_STRVAL(tmp)); >>> + snprintf(tmp_buf, Z_STRLEN(tmp), WDDX_NUMBER, Z_STRVAL(tmp)); >> >> >> *** This should most likely read sizeof(tmp_buf) *** >> >>> zval_dtor(&tmp); >>> >>> php_wddx_add_chunk(packet, tmp_buf); >>> @@ -624,17 +624,19 @@ >>> */ >>> void php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name, >>> int name_len TSRMLS_DC) >>> { >>> - char tmp_buf[WDDX_BUF_LEN]; >>> + char *tmp_buf; >>> char *name_esc; >>> int name_esc_len; >>> >>> if (name) { >>> name_esc = php_escape_html_entities(name, name_len, >>> &name_esc_len, 0, ENT_QUOTES, NULL TSRMLS_CC); >>> - sprintf(tmp_buf, WDDX_VAR_S, name_esc); >>> + tmp_buf = emalloc(name_esc_len + 1); >>> + snprintf(tmp_buf, name_esc_len, WDDX_VAR_S, name_esc); >> >> *** This should also most likely be sizeof(tmp_buf) *** >> >>> php_wddx_add_chunk(packet, tmp_buf); >>> + efree(tmp_buf); >>> efree(name_esc); >>> } >>> - >>> + >>> switch(Z_TYPE_P(var)) { >>> case IS_STRING: >>> php_wddx_serialize_string(packet, var); >> >> >> >> >> Best regards, >> Marcus >> >> >> > -- > Wbr, > Antony Dovgal 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(PHP_4_4) /ext/wddx wddx.c
Hello Marcus. What I did is basically backported this fix by Jani: http://cvs.php.net/viewcvs.cgi/php-src/ext/wddx/wddx.c?r1=1.119.2.1&r2=1.119.2.2 If you feel it's wrong - please fix it, though it works fine for me. On 20.05.2006 02:35, Marcus Boerger wrote: Hello Antony, see inplace comments below best regards marcus Friday, May 19, 2006, 12:37:32 PM, you wrote: tony2001Fri May 19 10:37:32 2006 UTC Modified files: (Branch: PHP_4_4) /php-src/ext/wddx wddx.c Log: MFH fix for #34306 (wddx_serialize_value() crashes with long array keys) http://cvs.php.net/viewcvs.cgi/php-src/ext/wddx/wddx.c?r1=1.96.2.6.2.4&r2=1.96.2.6.2.5&diff_format=u Index: php-src/ext/wddx/wddx.c diff -u php-src/ext/wddx/wddx.c:1.96.2.6.2.4 php-src/ext/wddx/wddx.c:1.96.2.6.2.5 --- php-src/ext/wddx/wddx.c:1.96.2.6.2.4Sun Apr 23 16:02:37 2006 +++ php-src/ext/wddx/wddx.c Fri May 19 10:37:32 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: wddx.c,v 1.96.2.6.2.4 2006/04/23 16:02:37 iliaa Exp $ */ +/* $Id: wddx.c,v 1.96.2.6.2.5 2006/05/19 10:37:32 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -432,7 +432,7 @@ tmp = *var; zval_copy_ctor(&tmp); convert_to_string(&tmp); - sprintf(tmp_buf, WDDX_NUMBER, Z_STRVAL(tmp)); + snprintf(tmp_buf, Z_STRLEN(tmp), WDDX_NUMBER, Z_STRVAL(tmp)); *** This should most likely read sizeof(tmp_buf) *** zval_dtor(&tmp); php_wddx_add_chunk(packet, tmp_buf); @@ -624,17 +624,19 @@ */ void php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name, int name_len TSRMLS_DC) { - char tmp_buf[WDDX_BUF_LEN]; + char *tmp_buf; char *name_esc; int name_esc_len; if (name) { name_esc = php_escape_html_entities(name, name_len, &name_esc_len, 0, ENT_QUOTES, NULL TSRMLS_CC); - sprintf(tmp_buf, WDDX_VAR_S, name_esc); + tmp_buf = emalloc(name_esc_len + 1); + snprintf(tmp_buf, name_esc_len, WDDX_VAR_S, name_esc); *** This should also most likely be sizeof(tmp_buf) *** php_wddx_add_chunk(packet, tmp_buf); + efree(tmp_buf); efree(name_esc); } - + switch(Z_TYPE_P(var)) { case IS_STRING: php_wddx_serialize_string(packet, var); Best regards, Marcus -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src / .gdbinit
helly Sat May 20 12:44:46 2006 UTC Modified files: /php-src.gdbinit Log: - In printzv show private/protected visibility and class in case of private http://cvs.php.net/viewcvs.cgi/php-src/.gdbinit?r1=1.17&r2=1.18&diff_format=u Index: php-src/.gdbinit diff -u php-src/.gdbinit:1.17 php-src/.gdbinit:1.18 --- php-src/.gdbinit:1.17 Mon Mar 13 22:54:05 2006 +++ php-src/.gdbinitSat May 20 12:44:46 2006 @@ -69,7 +69,7 @@ if ! $arg1 printf "{\n" set $ind = $ind + 1 - print_ht $zvalue->value.ht + print_ht $zvalue->value.ht 0 set $ind = $ind - 1 set $i = $ind while $i > 0 @@ -103,7 +103,7 @@ printf "(%d): ", $ht->nNumOfElements printf "{\n" set $ind = $ind + 1 - print_ht $ht + print_ht $ht 1 set $ind = $ind - 1 set $i = $ind while $i > 0 @@ -190,6 +190,7 @@ define print_ht set $ht = $arg0 + set $obj = $arg1 set $p = $ht->pListHead while $p != 0 @@ -201,8 +202,20 @@ set $i = $i - 1 end - if $p->nKeyLength > 0 - printf "\"%s\" => ", $p->key.arKey.s + if $p->nKeyLength > 0 + if $obj && $p->key.arKey.s[0] == 0 + if $p->key.arKey.s[1] == '*' + printf "\"protected %s\" => ", $p->key.arKey.s+3 + else + set $n = 1 + while $n < $p->nKeyLength && $p->key.arKey.s[$n] != 0 + set $n = $n + 1 + end + printf "\"private %s::%s\" => ", $p->key.arKey.s+1, $p->key.arKey.s+$n+1 + end + else + printf "\"%s\" => ", $p->key.arKey.s + end else printf "%d => ", $p->h end @@ -215,7 +228,7 @@ define print_ht set $ind = 1 printf "[0x%08x] {\n", $arg0 - print_ht $arg0 + print_ht $arg0 0 printf "}\n" end -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /tests/classes abstract_by_interface_001.phpt abstract_by_interface_002.phpt
helly Sat May 20 11:35:38 2006 UTC Added files: (Branch: PHP_5_2) /php-src/tests/classes abstract_by_interface_001.phpt abstract_by_interface_002.phpt Log: - MFH Add new tests http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/abstract_by_interface_001.phpt?view=markup&rev=1.1 Index: php-src/tests/classes/abstract_by_interface_001.phpt +++ php-src/tests/classes/abstract_by_interface_001.phpt --TEST-- ZE2 An abstract method may not be called --FILE-- ===DONE=== --EXPECTF-- object(Leaf)#%d (0) { } Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_001.php on line %d http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/abstract_by_interface_002.phpt?view=markup&rev=1.1 Index: php-src/tests/classes/abstract_by_interface_002.phpt +++ php-src/tests/classes/abstract_by_interface_002.phpt --TEST-- ZE2 An abstract method may not be called --FILE-- ===DONE=== --EXPECTF-- object(Leaf)#%d (0) { } Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_002.php on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /tests/classes abstract_by_interface_001.phpt abstract_by_interface_002.phpt
helly Sat May 20 11:34:58 2006 UTC Added files: /php-src/tests/classes abstract_by_interface_001.phpt abstract_by_interface_002.phpt Log: - Add new tests http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/abstract_by_interface_001.phpt?view=markup&rev=1.1 Index: php-src/tests/classes/abstract_by_interface_001.phpt +++ php-src/tests/classes/abstract_by_interface_001.phpt --TEST-- ZE2 An abstract method may not be called --FILE-- ===DONE=== --EXPECTF-- object(Leaf)#%d (0) { } Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_001.php on line %d http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/abstract_by_interface_002.phpt?view=markup&rev=1.1 Index: php-src/tests/classes/abstract_by_interface_002.phpt +++ php-src/tests/classes/abstract_by_interface_002.phpt --TEST-- ZE2 An abstract method may not be called --FILE-- ===DONE=== --EXPECTF-- object(Leaf)#%d (0) { } Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_002.php on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php