[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c /ext/simplexml/tests 036.phpt
colder Wed Jul 9 21:27:10 2008 UTC Added files: /php-src/ext/simplexml/tests036.phpt Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: Move SXI::count to SXE::count and make it user-friendly http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/php_simplexml.h?r1=1.29r2=1.30diff_format=u Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.29 php-src/ext/simplexml/php_simplexml.h:1.30 --- php-src/ext/simplexml/php_simplexml.h:1.29 Thu Jan 3 16:18:29 2008 +++ php-src/ext/simplexml/php_simplexml.h Wed Jul 9 21:27:10 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.29 2008/01/03 16:18:29 nlopess Exp $ */ +/* $Id: php_simplexml.h,v 1.30 2008/07/09 21:27:10 colder Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -68,6 +68,7 @@ zval *data; } iter; zval *tmp; + zend_function *fptr_count; } php_sxe_object; #ifdef ZTS http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.256r2=1.257diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.256 php-src/ext/simplexml/simplexml.c:1.257 --- php-src/ext/simplexml/simplexml.c:1.256 Fri Jun 27 15:47:21 2008 +++ php-src/ext/simplexml/simplexml.c Wed Jul 9 21:27:10 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.256 2008/06/27 15:47:21 felipe Exp $ */ +/* $Id: simplexml.c,v 1.257 2008/07/09 21:27:10 colder Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1868,14 +1868,12 @@ } /* }}} */ -static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */ +static int php_sxe_count_elements_helper(php_sxe_object *sxe, long *count TSRMLS_DC) /* {{{ */ { - php_sxe_object *sxe; xmlNodePtr node; zval*data; *count = 0; - sxe = php_sxe_fetch_object(object TSRMLS_CC); data = sxe-iter.data; sxe-iter.data = NULL; @@ -1897,6 +1895,42 @@ } /* }}} */ +static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */ +{ + php_sxe_object *intern; + intern = php_sxe_fetch_object(object TSRMLS_CC); + if (intern-fptr_count) { + zval *rv; + zend_call_method_with_0_params(object, intern-zo.ce, intern-fptr_count, count, rv); + if (rv) { + if (intern-tmp) { + zval_ptr_dtor(intern-tmp); + } + MAKE_STD_ZVAL(intern-tmp); + ZVAL_ZVAL(intern-tmp, rv, 1, 1); + convert_to_long(intern-tmp); + *count = (long) Z_LVAL_P(intern-tmp); + return SUCCESS; + } + return FAILURE; + } + return php_sxe_count_elements_helper(intern, count TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto int SimpleXMLIterator::count() + Get number of child elements */ +SXE_METHOD(count) +{ + long count = 0; + php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); + + php_sxe_count_elements_helper(sxe, count TSRMLS_CC); + + RETURN_LONG(count); +} +/* }}} */ + static zval *sxe_get_value(zval *z TSRMLS_DC) /* {{{ */ { zval *retval; @@ -2035,15 +2069,34 @@ static php_sxe_object* php_sxe_object_new(zend_class_entry *ce TSRMLS_DC) { php_sxe_object *intern; + zend_class_entry *parent = ce; + int inherited = 0; intern = ecalloc(1, sizeof(php_sxe_object)); intern-iter.type = SXE_ITER_NONE; intern-iter.nsprefix = NULL; intern-iter.name = NULL; + intern-fptr_count = NULL; zend_object_std_init(intern-zo, ce TSRMLS_CC); + while (parent) { + if (parent == sxe_class_entry) { + break; + } + + parent = parent-parent; + inherited = 1; + } + + if (inherited) { + zend_hash_find(ce-function_table, count, sizeof(count),(void **) intern-fptr_count); + if (intern-fptr_count-common.scope == parent) { + intern-fptr_count = NULL; + } + } + return intern; } /* }}} */ @@ -2538,6 +2591,7 @@ SXE_ME(addChild, NULL, ZEND_ACC_PUBLIC) SXE_ME(addAttribute, NULL, ZEND_ACC_PUBLIC) SXE_ME(__toString, NULL, ZEND_ACC_PUBLIC) + SXE_ME(count, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; /* }}} */ @@ -2586,7 +2640,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, Simplexml support, enabled); -
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c /ext/simplexml/tests profile12.phpt
helly Fri Apr 14 15:15:21 2006 UTC Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c /php-src/ext/simplexml/testsprofile12.phpt Log: - Fix properties access to children() result - Allow access by namespace prefix http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/php_simplexml.h?r1=1.24r2=1.25diff_format=u Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.24 php-src/ext/simplexml/php_simplexml.h:1.25 --- php-src/ext/simplexml/php_simplexml.h:1.24 Mon Feb 27 13:32:25 2006 +++ php-src/ext/simplexml/php_simplexml.h Fri Apr 14 15:15:21 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.24 2006/02/27 13:32:25 helly Exp $ */ +/* $Id: php_simplexml.h,v 1.25 2006/04/14 15:15:21 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -69,6 +69,7 @@ struct { char *name; char *nsprefix; + int isprefix; SXE_ITER type; zval *data; } iter; http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.205r2=1.206diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.205 php-src/ext/simplexml/simplexml.c:1.206 --- php-src/ext/simplexml/simplexml.c:1.205 Fri Apr 14 14:07:51 2006 +++ php-src/ext/simplexml/simplexml.c Fri Apr 14 15:15:21 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.205 2006/04/14 14:07:51 helly Exp $ */ +/* $Id: simplexml.c,v 1.206 2006/04/14 15:15:21 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -58,7 +58,7 @@ /* {{{ _node_as_zval() */ -static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, char *prefix TSRMLS_DC) +static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, char *nsprefix, int isprefix TSRMLS_DC) { php_sxe_object *subnode; @@ -69,8 +69,9 @@ if (name) { subnode-iter.name = xmlStrdup(name); } - if (prefix *prefix) { - subnode-iter.nsprefix = xmlStrdup(prefix); + if (nsprefix *nsprefix) { + subnode-iter.nsprefix = xmlStrdup(nsprefix); + subnode-iter.isprefix = isprefix; } php_libxml_increment_node_ptr((php_libxml_node_object *)subnode, node, NULL TSRMLS_CC); @@ -116,13 +117,13 @@ } } -static inline int match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) /* {{{ */ +static inline int match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name, int prefix) /* {{{ */ { if (name == NULL (node-ns == NULL || node-ns-prefix == NULL)) { return 1; } - if (node-ns (/*!xmlStrcmp(node-ns-prefix, name) ||*/ !xmlStrcmp(node-ns-href, name))) { + if (node-ns !xmlStrcmp(prefix ? node-ns-prefix : node-ns-href, name)) { return 1; } @@ -139,7 +140,7 @@ } while (node nodendx = offset) { SKIP_TEXT(node) - if (node-type == XML_ELEMENT_NODE match_ns(sxe, node, sxe-iter.nsprefix)) { + if (node-type == XML_ELEMENT_NODE match_ns(sxe, node, sxe-iter.nsprefix, sxe-iter.isprefix)) { if (sxe-iter.type == SXE_ITER_CHILD || ( sxe-iter.type == SXE_ITER_ELEMENT !xmlStrcmp(node-name, sxe-iter.name))) { if (nodendx == offset) { @@ -164,7 +165,7 @@ { while (node) { SKIP_TEXT(node) - if (node-type == XML_ELEMENT_NODE match_ns(sxe, node, sxe-iter.nsprefix)) { + if (node-type == XML_ELEMENT_NODE match_ns(sxe, node, sxe-iter.nsprefix, sxe-iter.isprefix)) { if (!xmlStrcmp(node-name, name)) { return node; } @@ -198,7 +199,7 @@ while (node) { SKIP_TEXT(node) - if (node-type == XML_ELEMENT_NODE match_ns(sxe, node, sxe-iter.nsprefix)) { + if (node-type == XML_ELEMENT_NODE match_ns(sxe, node, sxe-iter.nsprefix, sxe-iter.isprefix)) { if (!xmlStrcmp(node-name, *name)) { if (1||retnode) { @@ -276,9 +277,9 @@ if (Z_TYPE_P(member) != IS_LONG || sxe-iter.type == SXE_ITER_ATTRLIST) { if (Z_TYPE_P(member) == IS_LONG) { while (attr nodendx = Z_LVAL_P(member)) { - if ((!test || !xmlStrcmp(attr-name,
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c /ext/simplexml/tests 029.phpt
helly Mon Feb 27 13:32:25 2006 UTC Added files: /php-src/ext/simplexml/tests029.phpt Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: - Fix count/foreach interaction http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/php_simplexml.h?r1=1.23r2=1.24diff_format=u Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.23 php-src/ext/simplexml/php_simplexml.h:1.24 --- php-src/ext/simplexml/php_simplexml.h:1.23 Sun Feb 26 15:48:28 2006 +++ php-src/ext/simplexml/php_simplexml.h Mon Feb 27 13:32:25 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.23 2006/02/26 15:48:28 helly Exp $ */ +/* $Id: php_simplexml.h,v 1.24 2006/02/27 13:32:25 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -67,7 +67,6 @@ HashTable *properties; xmlXPathContextPtr xpath; struct { - int itertype; char *name; char *nsprefix; SXE_ITER type; http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.194r2=1.195diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.194 php-src/ext/simplexml/simplexml.c:1.195 --- php-src/ext/simplexml/simplexml.c:1.194 Mon Feb 27 11:55:23 2006 +++ php-src/ext/simplexml/simplexml.c Mon Feb 27 13:32:25 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.194 2006/02/27 11:55:23 helly Exp $ */ +/* $Id: simplexml.c,v 1.195 2006/02/27 13:32:25 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1438,9 +1438,14 @@ { php_sxe_object *sxe; xmlNodePtr node; + zval*data; *count = 0; sxe = php_sxe_fetch_object(object TSRMLS_CC); + + data = sxe-iter.data; + sxe-iter.data = NULL; + node = php_sxe_reset_iterator(sxe, 0 TSRMLS_CC); while (node) @@ -1449,6 +1454,10 @@ node = php_sxe_iterator_fetch(sxe, node-next, 0 TSRMLS_CC); } + if (sxe-iter.data) { + zval_ptr_dtor(sxe-iter.data); + } + sxe-iter.data = data; return SUCCESS; } @@ -2117,7 +2126,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, Simplexml support, enabled); - php_info_print_table_row(2, Revision, $Revision: 1.194 $); + php_info_print_table_row(2, Revision, $Revision: 1.195 $); php_info_print_table_row(2, Schema support, #ifdef LIBXML_SCHEMAS_ENABLED enabled); http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/tests/029.phpt?view=markuprev=1.1 Index: php-src/ext/simplexml/tests/029.phpt +++ php-src/ext/simplexml/tests/029.phpt --TEST-- SimpleXML: foreach and count --SKIPIF-- ?php if (!extension_loaded(simplexml)) print skip; ? --FILE-- ?php $xml =EOF people person name=Joe/ person name=John children person name=Joe/ /children /person person name=Jane/ /people EOF; $people = simplexml_load_string($xml); foreach($people as $person) { var_dump((string)$person['name']); var_dump(count($people)); var_dump(count($person)); } ? ===DONE=== --EXPECTF-- string(3) Joe int(3) int(0) string(4) John int(3) int(1) string(4) Jane int(3) int(0) ===DONE=== --UEXPECTF-- unicode(3) Joe int(3) int(0) unicode(4) John int(3) int(1) unicode(4) Jane int(3) int(0) ===DONE=== -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c /ext/simplexml/tests 006.phpt bug35785.phpt
helly Sun Feb 26 15:48:28 2006 UTC Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c /php-src/ext/simplexml/tests006.phpt bug35785.phpt Log: - Use get_property_ptr_ptr handler to prevent SEGV as in bug #35785 # Issue not completley solved though http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/php_simplexml.h?r1=1.22r2=1.23diff_format=u Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.22 php-src/ext/simplexml/php_simplexml.h:1.23 --- php-src/ext/simplexml/php_simplexml.h:1.22 Sun Jan 1 13:09:53 2006 +++ php-src/ext/simplexml/php_simplexml.h Sun Feb 26 15:48:28 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.22 2006/01/01 13:09:53 sniper Exp $ */ +/* $Id: php_simplexml.h,v 1.23 2006/02/26 15:48:28 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -53,6 +53,13 @@ #endif PHP_MINFO_FUNCTION(simplexml); +typedef enum { + SXE_ITER_NONE = 0, + SXE_ITER_ELEMENT = 1, + SXE_ITER_CHILD= 2, + SXE_ITER_ATTRLIST = 3 +} SXE_ITER; + typedef struct { zend_object zo; php_libxml_node_ptr *node; @@ -63,16 +70,12 @@ int itertype; char *name; char *nsprefix; - int type; + SXE_ITER type; zval *data; } iter; + zval *tmp; } php_sxe_object; -#define SXE_ITER_NONE 0 -#define SXE_ITER_ELEMENT 1 -#define SXE_ITER_CHILD 2 -#define SXE_ITER_ATTRLIST 3 - #ifdef ZTS #define SIMPLEXML_G(v) TSRMG(simplexml_globals_id, zend_simplexml_globals *, v) #else http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.191r2=1.192diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.191 php-src/ext/simplexml/simplexml.c:1.192 --- php-src/ext/simplexml/simplexml.c:1.191 Sun Feb 26 13:37:54 2006 +++ php-src/ext/simplexml/simplexml.c Sun Feb 26 15:48:28 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.191 2006/02/26 13:37:54 helly Exp $ */ +/* $Id: simplexml.c,v 1.192 2006/02/26 15:48:28 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -58,7 +58,7 @@ /* {{{ _node_as_zval() */ -static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, int itertype, char *name, char *prefix TSRMLS_DC) +static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, char *prefix TSRMLS_DC) { php_sxe_object *subnode; @@ -160,7 +160,6 @@ } /* }}} */ -#if SXE_ELEMENT_BY_NAME static xmlNodePtr sxe_find_element_by_name(php_sxe_object *sxe, xmlNodePtr node, char *name TSRMLS_DC) /* {{{ */ { while (node) { @@ -176,7 +175,7 @@ return NULL; } /* }}} */ -static xmlNodePtr sxe_get_element_by_name(php_sxe_object *sxe, xmlNodePtr node, char **name, int *type TSRMLS_DC) /* {{{ */ +static xmlNodePtr sxe_get_element_by_name(php_sxe_object *sxe, xmlNodePtr node, char **name, SXE_ITER *type TSRMLS_DC) /* {{{ */ { int orgtype; xmlNodePtr orgnode = node; @@ -223,7 +222,6 @@ return NULL; } /* }}} */ -#endif /* SXE_ELEMENT_BY_NAME */ /* {{{ sxe_prop_dim_read() */ @@ -360,6 +358,11 @@ { zval value_copy; + if (!value) + { + xmlNodeSetContentLen(node, , 0); + return; + } switch (Z_TYPE_P(value)) { case IS_LONG: case IS_BOOL: @@ -388,7 +391,7 @@ /* {{{ sxe_property_write() */ -static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool elements, zend_bool attribs TSRMLS_DC) +static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool elements, zend_bool attribs, xmlNodePtr *pnewnode TSRMLS_DC) { php_sxe_object *sxe; char *name; @@ -463,18 +466,20 @@ mynode = node; - switch (Z_TYPE_P(value)) { - case IS_LONG: - case IS_BOOL: - case IS_DOUBLE: - case IS_NULL: - case IS_UNICODE: - convert_to_string(value); - break; - case IS_STRING: - break; - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, It is not yet possible to assign complex types to %s, attribs ? attributes : properties); + if (value) { + switch (Z_TYPE_P(value)) { + case IS_LONG: + case IS_BOOL: + case IS_DOUBLE: + case IS_NULL: + case
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c /ext/standard array.c
sniper Thu Jun 30 07:15:00 2005 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c /php-src/ext/standard array.c Log: - Unify (+ spl can't be build shared so COMPILE_DL_SPL http://cvs.php.net/diff.php/php-src/ext/simplexml/php_simplexml.h?r1=1.18r2=1.19ty=u Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.18 php-src/ext/simplexml/php_simplexml.h:1.19 --- php-src/ext/simplexml/php_simplexml.h:1.18 Thu Feb 12 19:02:19 2004 +++ php-src/ext/simplexml/php_simplexml.h Thu Jun 30 07:14:56 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.18 2004/02/13 00:02:19 fmk Exp $ */ +/* $Id: php_simplexml.h,v 1.19 2005/06/30 11:14:56 sniper Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -48,7 +48,7 @@ PHP_MINIT_FUNCTION(simplexml); PHP_MSHUTDOWN_FUNCTION(simplexml); -#if HAVE_SPL !defined(COMPILE_DL_SPL) +#ifdef HAVE_SPL PHP_RINIT_FUNCTION(simplexml); #endif PHP_MINFO_FUNCTION(simplexml); http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.148r2=1.149ty=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.148 php-src/ext/simplexml/simplexml.c:1.149 --- php-src/ext/simplexml/simplexml.c:1.148 Fri Jun 17 07:35:22 2005 +++ php-src/ext/simplexml/simplexml.c Thu Jun 30 07:14:56 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.148 2005/06/17 11:35:22 sniper Exp $ */ +/* $Id: simplexml.c,v 1.149 2005/06/30 11:14:56 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -34,7 +34,7 @@ #include php_simplexml_exports.h #include zend_exceptions.h #include zend_interfaces.h -#if HAVE_SPL !defined(COMPILE_DL_SPL) +#ifdef HAVE_SPL #include ext/spl/spl_sxe.h #endif @@ -1709,7 +1709,7 @@ sxe_ze1_object_handlers.get_class_name = zend_get_std_object_handlers()-get_class_name; sxe_ze1_object_handlers.clone_obj = sxe_object_ze1_clone; -#if HAVE_SPL !defined(COMPILE_DL_SPL) +#ifdef HAVE_SPL if (zend_get_module_started(spl) == SUCCESS) { PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU); } @@ -1735,7 +1735,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, Simplexml support, enabled); - php_info_print_table_row(2, Revision, $Revision: 1.148 $); + php_info_print_table_row(2, Revision, $Revision: 1.149 $); php_info_print_table_row(2, Schema support, #ifdef LIBXML_SCHEMAS_ENABLED enabled); http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.304r2=1.305ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.304 php-src/ext/standard/array.c:1.305 --- php-src/ext/standard/array.c:1.304 Tue Jun 21 08:10:51 2005 +++ php-src/ext/standard/array.cThu Jun 30 07:15:00 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: array.c,v 1.304 2005/06/21 12:10:51 dmitry Exp $ */ +/* $Id: array.c,v 1.305 2005/06/30 11:15:00 sniper Exp $ */ #include php.h #include php_ini.h @@ -46,7 +46,7 @@ #include php_string.h #include php_rand.h #include php_smart_str.h -#if HAVE_SPL +#ifdef HAVE_SPL #include ext/spl/spl_array.h #endif @@ -319,7 +319,7 @@ RETURN_LONG (php_count_recursive (array, mode TSRMLS_CC)); break; case IS_OBJECT: { -#if HAVE_SPL +#ifdef HAVE_SPL /* it the object implements Countable we call its count() method */ zval *retval; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c
rrichards Thu Jan 22 16:30:16 2004 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: Fix bug #27010: segfault after returning nodes with children() Fix segfault in match_ns when matching prefix and node without ns some general cleanup and code consilidation better write handling - engine support dependent better isset handling - engine support dependent namespace fixes for reading/writing http://cvs.php.net/diff.php/php-src/ext/simplexml/php_simplexml.h?r1=1.16r2=1.17ty=u Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.16 php-src/ext/simplexml/php_simplexml.h:1.17 --- php-src/ext/simplexml/php_simplexml.h:1.16 Sun Jan 18 10:15:55 2004 +++ php-src/ext/simplexml/php_simplexml.h Thu Jan 22 16:30:14 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.16 2004/01/18 15:15:55 helly Exp $ */ +/* $Id: php_simplexml.h,v 1.17 2004/01/22 21:30:14 rrichards Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -59,7 +59,6 @@ HashTable *properties; xmlXPathContextPtr xpath; struct { - php_libxml_node_ptr *node; int itertype; char *name; char *nsprefix; @@ -70,9 +69,8 @@ #define SXE_ITER_NONE 0 #define SXE_ITER_ELEMENT 1 -#define SXE_ITER_ATTR 2 -#define SXE_ITER_CHILD 3 -#define SXE_ITER_ATTRLIST 4 +#define SXE_ITER_CHILD 2 +#define SXE_ITER_ATTRLIST 3 #ifdef ZTS #define SIMPLEXML_G(v) TSRMG(simplexml_globals_id, zend_simplexml_globals *, v) http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.121r2=1.122ty=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.121 php-src/ext/simplexml/simplexml.c:1.122 --- php-src/ext/simplexml/simplexml.c:1.121 Wed Jan 21 09:04:46 2004 +++ php-src/ext/simplexml/simplexml.c Thu Jan 22 16:30:14 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.121 2004/01/21 14:04:46 rrichards Exp $ */ +/* $Id: simplexml.c,v 1.122 2004/01/22 21:30:14 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -121,14 +121,41 @@ return 1; } - if (!xmlStrcmp(node-ns-href, name)) { + if (node-ns !xmlStrcmp(node-ns-href, name)) { return 1; } return 0; } /* }}} */ - + +/* {{{ sxe_get_element_node() + */ +static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, xmlNodePtr node) { + long nodendx = 0; + + if (sxe-iter.type == SXE_ITER_NONE) { + return NULL; + } + while (node nodendx = offset) { + SKIP_TEXT(node) + if (node-type == XML_ELEMENT_NODE match_ns(sxe, node, sxe-iter.nsprefix)) { + if (sxe-iter.type == SXE_ITER_CHILD || ( + sxe-iter.type == SXE_ITER_ELEMENT !xmlStrcmp(node-name, sxe-iter.name))) { + if (nodendx == offset) { + break; + } + nodendx++; + } + } +next_iter: + node = node-next; + } + + return node; +} +/* }}} */ + /* {{{ sxe_prop_dim_read() */ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, zend_bool silent TSRMLS_DC) @@ -140,7 +167,6 @@ xmlAttrPtr attr; zvaltmp_zv; int nodendx = 0; - char*prefix; sxe = php_sxe_fetch_object(object TSRMLS_CC); @@ -179,7 +205,7 @@ while (attr nodendx = Z_LVAL_P(member)) { if (match_ns(sxe, (xmlNodePtr) attr, sxe-iter.nsprefix)) { if (nodendx == Z_LVAL_P(member)) { - _node_as_zval(sxe, (xmlNodePtr) attr, return_value, SXE_ITER_NONE, NULL, NULL TSRMLS_CC); + _node_as_zval(sxe, (xmlNodePtr) attr, return_value, SXE_ITER_NONE, NULL, sxe-iter.nsprefix TSRMLS_CC); break; } nodendx++; @@ -189,7 +215,7 @@ } else { while (attr) { if (!xmlStrcmp(attr-name, name) match_ns(sxe, (xmlNodePtr) attr, sxe-iter.nsprefix)) { -
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c
helly Sun Jan 18 08:19:41 2004 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: Export access to class_entry by function. Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.14 php-src/ext/simplexml/php_simplexml.h:1.15 --- php-src/ext/simplexml/php_simplexml.h:1.14 Sat Jan 17 16:22:26 2004 +++ php-src/ext/simplexml/php_simplexml.h Sun Jan 18 08:19:41 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.14 2004/01/17 21:22:26 sterling Exp $ */ +/* $Id: php_simplexml.h,v 1.15 2004/01/18 13:19:41 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -80,6 +80,8 @@ #define SIMPLEXML_G(v) (simplexml_globals.v) #endif +PHP_API zend_class_entry *sxe_get_element_class_entry(); + #endif /* Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.111 php-src/ext/simplexml/simplexml.c:1.112 --- php-src/ext/simplexml/simplexml.c:1.111 Sat Jan 17 16:22:26 2004 +++ php-src/ext/simplexml/simplexml.c Sun Jan 18 08:19:41 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.111 2004/01/17 21:22:26 sterling Exp $ */ +/* $Id: simplexml.c,v 1.112 2004/01/18 13:19:41 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -34,7 +34,12 @@ #include zend_default_classes.h #include zend_interfaces.h -zend_class_entry *sxe_class_entry; +zend_class_entry *sxe_class_entry = NULL; + +PHP_API zend_class_entry *sxe_get_element_class_entry() +{ + return sxe_class_entry; +} #define SXE_ME(func, arg_info, flags) PHP_ME(simplexml_element, func, arg_info, flags) @@ -1490,7 +1495,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, Simplexml support, enabled); - php_info_print_table_row(2, Revision, $Revision: 1.111 $); + php_info_print_table_row(2, Revision, $Revision: 1.112 $); php_info_print_table_row(2, Schema support, #ifdef LIBXML_SCHEMAS_ENABLED enabled); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c
helly Sun Jan 18 10:15:56 2004 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: Enable inherited classes inside SPL and respect order of module init. Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.15 php-src/ext/simplexml/php_simplexml.h:1.16 --- php-src/ext/simplexml/php_simplexml.h:1.15 Sun Jan 18 08:19:41 2004 +++ php-src/ext/simplexml/php_simplexml.h Sun Jan 18 10:15:55 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.15 2004/01/18 13:19:41 helly Exp $ */ +/* $Id: php_simplexml.h,v 1.16 2004/01/18 15:15:55 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -80,7 +80,7 @@ #define SIMPLEXML_G(v) (simplexml_globals.v) #endif -PHP_API zend_class_entry *sxe_get_element_class_entry(); +ZEND_API zend_class_entry *sxe_get_element_class_entry(); #endif Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.112 php-src/ext/simplexml/simplexml.c:1.113 --- php-src/ext/simplexml/simplexml.c:1.112 Sun Jan 18 08:19:41 2004 +++ php-src/ext/simplexml/simplexml.c Sun Jan 18 10:15:56 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.112 2004/01/18 13:19:41 helly Exp $ */ +/* $Id: simplexml.c,v 1.113 2004/01/18 15:15:56 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -31,12 +31,16 @@ #include ext/standard/info.h #include ext/standard/php_string.h #include php_simplexml.h +#include simplexml.h #include zend_default_classes.h #include zend_interfaces.h +#if HAVE_SPL +#include ext/spl/spl_sxe.h +#endif zend_class_entry *sxe_class_entry = NULL; -PHP_API zend_class_entry *sxe_get_element_class_entry() +ZEND_API zend_class_entry *sxe_get_element_class_entry() { return sxe_class_entry; } @@ -45,23 +49,8 @@ #define SXE_METHOD(func) PHP_METHOD(simplexml_element, func) -#define SKIP_TEXT(__p) \ - if ((__p)-type == XML_TEXT_NODE) { \ - goto next_iter; \ - } - -static php_sxe_object *php_sxe_object_new(zend_class_entry *ce TSRMLS_DC); static zend_object_value php_sxe_register_object(php_sxe_object * TSRMLS_DC); -/* {{{ php_sxe_fetch_object() - */ -static inline php_sxe_object * -php_sxe_fetch_object(zval *object TSRMLS_DC) -{ - return (php_sxe_object *) zend_object_store_get_object(object TSRMLS_CC); -} -/* }}} */ - /* {{{ _node_as_zval() */ static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, int itertype, char *name, char *prefix TSRMLS_DC) @@ -106,8 +95,6 @@ } \ } -static void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC); - static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node TSRMLS_DC) { php_sxe_object *intern; xmlNodePtr retnode = NULL; @@ -1053,7 +1040,7 @@ /* {{{ sxe_object_new() */ -static zend_object_value +ZEND_API zend_object_value sxe_object_new(zend_class_entry *ce TSRMLS_DC) { php_sxe_object*intern; @@ -1186,7 +1173,7 @@ php_sxe_iterator_rewind, }; -static void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC) +ZEND_API void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC) { xmlNodePtr node; char *prefix; @@ -1305,16 +1292,12 @@ } -static void php_sxe_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) +ZEND_API void php_sxe_move_forward_iterator(php_sxe_object *sxe TSRMLS_DC) { xmlNodePtr node; php_sxe_object *intern; - php_sxe_object *sxe; char *prefix; - php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - sxe = iterator-sxe; - if (sxe-iter.data) { intern = (php_sxe_object *)zend_object_store_get_object(sxe-iter.data TSRMLS_CC); GET_NODE(intern, node) @@ -1366,6 +1349,12 @@ } } +static void php_sxe_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) +{ + php_sxe_iterator *iterator = (php_sxe_iterator *)iter; + php_sxe_move_forward_iterator(iterator-sxe TSRMLS_CC); +} + static void php_sxe_iterator_rewind(zend_object_iterator *iter TSRMLS_DC) { php_sxe_object *sxe; @@ -1485,6 +1474,12 @@ sxe_object_handlers.get_class_entry = zend_get_std_object_handlers()-get_class_entry; sxe_object_handlers.get_class_name = zend_get_std_object_handlers()-get_class_name; +#if HAVE_SPL + if (zend_get_module_started(spl) == SUCCESS) { + PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU); + } +#endif /* HAVE_SPL */ + return SUCCESS; } /* }}} */ @@ -1495,7 +1490,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, Simplexml support, enabled); - php_info_print_table_row(2, Revision, $Revision: 1.112 $); +
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c /ext/simplexml/tests profile04.phpt profile05.phpt profile06.phpt profile07.phpt profile10.phpt
sterlingSat Jan 17 16:22:27 2004 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c /php-src/ext/simplexml/testsprofile04.phpt profile05.phpt profile06.phpt profile07.phpt profile10.phpt Log: namespace accesses are now soley URI based as opposed to prefix based. Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.13 php-src/ext/simplexml/php_simplexml.h:1.14 --- php-src/ext/simplexml/php_simplexml.h:1.13 Sat Jan 17 14:41:31 2004 +++ php-src/ext/simplexml/php_simplexml.h Sat Jan 17 16:22:26 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.13 2004/01/17 19:41:31 helly Exp $ */ +/* $Id: php_simplexml.h,v 1.14 2004/01/17 21:22:26 sterling Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -53,16 +53,10 @@ PHP_MINFO_FUNCTION(simplexml); typedef struct { - xmlHashTablePtr nsmap; - int refcount; -} simplexml_nsmap; - -typedef struct { zend_object zo; php_libxml_node_ptr *node; php_libxml_ref_obj *document; HashTable *properties; - simplexml_nsmap *nsmapptr; xmlXPathContextPtr xpath; struct { php_libxml_node_ptr *node; Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.110 php-src/ext/simplexml/simplexml.c:1.111 --- php-src/ext/simplexml/simplexml.c:1.110 Sat Jan 17 14:41:31 2004 +++ php-src/ext/simplexml/simplexml.c Sat Jan 17 16:22:26 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.110 2004/01/17 19:41:31 helly Exp $ */ +/* $Id: simplexml.c,v 1.111 2004/01/17 21:22:26 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -66,8 +66,6 @@ subnode = php_sxe_object_new(sxe-zo.ce TSRMLS_CC); subnode-document = sxe-document; subnode-document-refcount++; - subnode-nsmapptr = sxe-nsmapptr; - subnode-nsmapptr-refcount++; subnode-iter.type = itertype; if (name) { subnode-iter.name = xmlStrdup(name); @@ -126,28 +124,12 @@ static inline int match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) { - xmlChar *prefix = NULL; - - if (name == NULL (node-ns == NULL || node-ns-prefix == NULL)) { + if (name == NULL (node-ns == NULL || node-ns-href == NULL)) { return 1; } - - if (node-ns) { - if (sxe-nsmapptr) { - prefix = xmlHashLookup(sxe-nsmapptr-nsmap, node-ns-href); - } - - if (prefix == NULL) { - prefix = (xmlChar*)node-ns-prefix; - } - - if (prefix == NULL) { - return 0; - } - - if (!xmlStrcmp(prefix, name)) { - return 1; - } + + if (!xmlStrcmp(node-ns-href, name)) { + return 1; } return 0; @@ -597,8 +579,6 @@ subnode = php_sxe_object_new(sxe_ref-zo.ce TSRMLS_CC); subnode-document = sxe_ref-document; subnode-document-refcount++; - subnode-nsmapptr = sxe_ref-nsmapptr; - subnode-nsmapptr-refcount++; php_libxml_increment_node_ptr((php_libxml_node_object *)subnode, node, NULL TSRMLS_CC); (*value)-type = IS_OBJECT; @@ -712,16 +692,6 @@ } /* }}} */ -/* {{{ simplexml_ce_xpath_register_ns() - */ -static void -simplexml_ce_xpath_register_ns(char *prefix, xmlXPathContext *xpath, char *href) -{ - xmlXPathRegisterNs(xpath, prefix, href); -} -/* }}} */ - - /* {{{ xpath() */ SXE_METHOD(xpath) @@ -752,7 +722,6 @@ sxe-xpath-node = sxe-node-node; ns = xmlGetNsList((xmlDocPtr) sxe-document-ptr, (xmlNodePtr) sxe-node-node); - if (ns != NULL) { while (ns[nsnbr] != NULL) { nsnbr++; @@ -762,14 +731,7 @@ sxe-xpath-namespaces = ns; sxe-xpath-nsNr = nsnbr; - /* Register namespaces added in simplexml_cs_register_ns() */ - xmlHashScan((xmlHashTablePtr) sxe-nsmapptr-nsmap, (xmlHashScanner) simplexml_ce_xpath_register_ns, sxe-xpath); - retval = xmlXPathEval(query, sxe-xpath); - - /* Cleanup registered namespaces added in simplexml_cs_register_ns() */ - xmlXPathRegisteredNsCleanup(sxe-xpath); - if (ns != NULL) { xmlFree(ns); sxe-xpath-namespaces = NULL; @@ -811,26 +773,6 @@ } /* }}} */ -/* {{{ simplexml_ce_register_ns() - */ -SXE_METHOD(register_ns) -{ - php_sxe_object *sxe; - char *nsname; - char *nsvalue; - int nsname_len; -
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c
sterlingFri Jan 9 01:12:32 2004 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: Remove these initializers as they are unused. Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.11 php-src/ext/simplexml/php_simplexml.h:1.12 --- php-src/ext/simplexml/php_simplexml.h:1.11 Thu Jan 8 12:32:46 2004 +++ php-src/ext/simplexml/php_simplexml.h Fri Jan 9 01:12:29 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.11 2004/01/08 17:32:46 sniper Exp $ */ +/* $Id: php_simplexml.h,v 1.12 2004/01/09 06:12:29 sterling Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -47,9 +47,9 @@ #include libxml/xmlschemas.h PHP_MINIT_FUNCTION(simplexml); -PHP_MSHUTDOWN_FUNCTION(simplexml); +#if HAVE_SPL !defined(COMPILE_DL_SPL) PHP_RINIT_FUNCTION(simplexml); -PHP_RSHUTDOWN_FUNCTION(simplexml); +#endif PHP_MINFO_FUNCTION(simplexml); typedef struct { @@ -82,7 +82,6 @@ #endif - /* * Local variables: * tab-width: 4 Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.101 php-src/ext/simplexml/simplexml.c:1.102 --- php-src/ext/simplexml/simplexml.c:1.101 Thu Jan 8 17:40:08 2004 +++ php-src/ext/simplexml/simplexml.c Fri Jan 9 01:12:29 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.101 2004/01/08 22:40:08 sterling Exp $ */ +/* $Id: simplexml.c,v 1.102 2004/01/09 06:12:29 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1578,9 +1578,13 @@ simplexml, simplexml_functions, PHP_MINIT(simplexml), - PHP_MSHUTDOWN(simplexml), - PHP_RINIT(simplexml), - PHP_RSHUTDOWN(simplexml), + NULL, +#if HAVE_SPL !defined(COMPILE_DL_SPL) + PHP_RINIT(simplexml), +#else + NULL, +#endif + NULL, PHP_MINFO(simplexml), 0.1, STANDARD_MODULE_PROPERTIES @@ -1631,32 +1635,16 @@ } /* }}} */ -/* {{{ PHP_MSHUTDOWN_FUNCTION(simplexml) - */ -PHP_MSHUTDOWN_FUNCTION(simplexml) -{ - return SUCCESS; -} -/* }}} */ - +#if HAVE_SPL !defined(COMPILE_DL_SPL) /* {{{ PHP_RINIT_FUNCTION(simplexml) */ PHP_RINIT_FUNCTION(simplexml) { -#if HAVE_SPL !defined(COMPILE_DL_SPL) zend_class_implements(sxe_class_entry TSRMLS_CC, 1, spl_ce_RecursiveIterator); -#endif - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_RSHUTDOWN_FUNCTION(simplexml) - */ -PHP_RSHUTDOWN_FUNCTION(simplexml) -{ return SUCCESS; } /* }}} */ +#endif /* {{{ PHP_MINFO_FUNCTION(simplexml) */ @@ -1664,7 +1652,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, Simplexml support, enabled); - php_info_print_table_row(2, Revision, $Revision: 1.101 $); + php_info_print_table_row(2, Revision, $Revision: 1.102 $); php_info_print_table_row(2, Schema support, #ifdef LIBXML_SCHEMAS_ENABLED enabled); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c /ext/simplexml/tests 006.phpt 006.xml
helly Sun Nov 23 11:20:59 2003 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c /php-src/ext/simplexml/tests006.phpt 006.xml Log: Several improvements to the simplexml_element object: - Allow to use it as an instance of Iterator - Prepareto use it as a normal object, including spcialization Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.8 php-src/ext/simplexml/php_simplexml.h:1.9 --- php-src/ext/simplexml/php_simplexml.h:1.8 Sun Oct 26 11:00:58 2003 +++ php-src/ext/simplexml/php_simplexml.h Sun Nov 23 11:20:57 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.8 2003/10/26 16:00:58 rrichards Exp $ */ +/* $Id: php_simplexml.h,v 1.9 2003/11/23 16:20:57 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -64,6 +64,12 @@ HashTable *properties; simplexml_nsmap *nsmapptr; xmlXPathContextPtr xpath; + struct { + xmlNodePtrnode; + char *name; + int namelen; + zval *data; + } iter; } php_sxe_object; Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.85 php-src/ext/simplexml/simplexml.c:1.86 --- php-src/ext/simplexml/simplexml.c:1.85 Fri Nov 14 02:41:05 2003 +++ php-src/ext/simplexml/simplexml.c Sun Nov 23 11:20:57 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.85 2003/11/14 07:41:05 helly Exp $ */ +/* $Id: simplexml.c,v 1.86 2003/11/23 16:20:57 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -30,8 +30,17 @@ #include ext/standard/info.h #include php_simplexml.h +#if HAVE_SPL +#include ext/spl/spl_iterators.h +#endif + + zend_class_entry *sxe_class_entry; +#define SXE_ME(func, arg_info, flags) PHP_ME(simplexml_element, func, arg_info, flags) + +#define SXE_METHOD(func) PHP_METHOD(simplexml_element, func) + #define SKIP_TEXT(__p) \ if ((__p)-type == XML_TEXT_NODE) { \ goto next_iter; \ @@ -51,8 +60,7 @@ /* {{{ _node_as_zval() */ -static void -_node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value TSRMLS_DC) +static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value TSRMLS_DC) { php_sxe_object *subnode; @@ -118,8 +126,7 @@ /* {{{ sxe_prop_dim_read() */ -static zval * -sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, zend_bool silent TSRMLS_DC) +static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, zend_bool silent TSRMLS_DC) { zval *return_value; zval *value = NULL; @@ -224,8 +231,7 @@ /* {{{ sxe_property_read() */ -static zval * -sxe_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC) +static zval * sxe_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC) { return sxe_prop_dim_read(object, member, 1, 0, silent TSRMLS_CC); } @@ -233,7 +239,7 @@ /* {{{ sxe_dimension_read() */ -static zval *sxe_dimension_read(zval *object, zval *offset TSRMLS_DC) +static zval * sxe_dimension_read(zval *object, zval *offset TSRMLS_DC) { return sxe_prop_dim_read(object, offset, 0, 1, 0 TSRMLS_CC); } @@ -641,10 +647,9 @@ } /* }}} */ -/* {{{ simplexml_ce_xpath_search() - */ -static void -simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAMETERS) +/* {{{ xsearch() + */ +SXE_METHOD(xsearch) { php_sxe_object*sxe; zval *value; @@ -694,8 +699,7 @@ _node_as_zval(sxe, result-nodeTab[i], value TSRMLS_CC); } add_next_index_zval(return_value, value); - } - + } } /* }}} */ @@ -775,12 +779,26 @@ } /* }}} */ +/* {{{ validate_schema_file + */ +SXE_METHOD(validate_schema_file) +{ + simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE); +} +/* }}} */ + +/* {{{ validate_schema_buffer + */ +SXE_METHOD(validate_schema_buffer) +{ + simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_BLOB); +} +/* }}} */ #endif /* {{{ simplexml_ce_register_ns() */ -static void -simplexml_ce_register_ns(INTERNAL_FUNCTION_PARAMETERS) +SXE_METHOD(register_ns) { php_sxe_object *sxe; char *nsname; @@ -800,8 +818,7 @@ /* {{{ simplexml_ce_to_xml_string() */ -static void -simplexml_ce_to_xml_string(INTERNAL_FUNCTION_PARAMETERS) +SXE_METHOD(to_xml_string) { php_sxe_object *sxe; xmlChar *strval; @@ -822,8 +839,7 @@ /* {{{ simplexml_ce_to_xml_file() */ -static void -simplexml_ce_to_xml_file(INTERNAL_FUNCTION_PARAMETERS) +SXE_METHOD(to_xml_file) {
[PHP-CVS] cvs: php-src /ext/simplexml php_simplexml.h simplexml.c
helly Sat Oct 25 17:08:40 2003 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: Fix memleaks Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.6 php-src/ext/simplexml/php_simplexml.h:1.7 --- php-src/ext/simplexml/php_simplexml.h:1.6 Sat Jun 14 14:15:50 2003 +++ php-src/ext/simplexml/php_simplexml.h Sat Oct 25 17:08:33 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.6 2003/06/14 18:15:50 rrichards Exp $ */ +/* $Id: php_simplexml.h,v 1.7 2003/10/25 21:08:33 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -62,6 +62,7 @@ simplexml_ref_obj *document; xmlHashTablePtr nsmap; xmlXPathContextPtr xpath; + HashTable *properties; } php_sxe_object; Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.66 php-src/ext/simplexml/simplexml.c:1.67 --- php-src/ext/simplexml/simplexml.c:1.66 Sat Oct 25 16:28:39 2003 +++ php-src/ext/simplexml/simplexml.c Sat Oct 25 17:08:33 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: simplexml.c,v 1.66 2003/10/25 20:28:39 helly Exp $ */ +/* $Id: simplexml.c,v 1.67 2003/10/25 21:08:33 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -350,7 +350,7 @@ /* {{{ _get_base_node_value() */ static void -_get_base_node_value(xmlNodePtr node, zval **value TSRMLS_DC) +_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value TSRMLS_DC) { php_sxe_object *subnode; char *contents; @@ -364,14 +364,13 @@ } } else { subnode = php_sxe_object_new(TSRMLS_C); - subnode-document = emalloc(sizeof(simplexml_ref_obj)); - subnode-document-refcount = 1; - subnode-document-ptr = node-doc; + subnode-document = sxe_ref-document; + subnode-document-refcount++; subnode-node = node; (*value)-type = IS_OBJECT; (*value)-value.obj = php_sxe_register_object(subnode TSRMLS_CC); - zval_add_ref(value); + /*zval_add_ref(value);*/ } } /* }}} */ @@ -391,18 +390,24 @@ ulongh; int namelen; - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); - sxe = php_sxe_fetch_object(object TSRMLS_CC); + if (sxe-properties) { + zend_hash_clean(sxe-properties); + rv = sxe-properties; + } else { + ALLOC_HASHTABLE(rv); + zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); + sxe-properties = rv; + } + GET_NODE(sxe, node); node = node-children; while (node) { SKIP_TEXT(node); - _get_base_node_value(node, value TSRMLS_CC); + _get_base_node_value(sxe, node, value TSRMLS_CC); name = (char *) node-name; namelen = xmlStrlen(node-name) + 1; @@ -890,6 +895,11 @@ if (sxe-xpath) { xmlXPathFreeContext(sxe-xpath); } + + if (sxe-properties) { + zend_hash_destroy(sxe-properties); + FREE_HASHTABLE(sxe-properties); + } efree(object); } @@ -909,6 +919,7 @@ intern-document = NULL; intern-nsmap = NULL; intern-xpath = NULL; + intern-properties = NULL; ALLOC_HASHTABLE(intern-zo.properties); zend_hash_init(intern-zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); @@ -1075,7 +1086,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, Simplexml support, enabled); - php_info_print_table_row(2, Revision, $Revision: 1.66 $); + php_info_print_table_row(2, Revision, $Revision: 1.67 $); php_info_print_table_end(); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php