@@ -78,10 +78,10 @@ static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE
78
78
}
79
79
/* }}} */
80
80
81
- static xmlNodePtr php_sxe_get_first_node_non_destructive (php_sxe_object * sxe , xmlNodePtr node )
81
+ static xmlNodePtr php_sxe_get_first_node (php_sxe_object * sxe , xmlNodePtr node )
82
82
{
83
83
if (sxe && sxe -> iter .type != SXE_ITER_NONE ) {
84
- return php_sxe_reset_iterator_no_clear_iter_data (sxe , false );
84
+ return php_sxe_reset_iterator (sxe , 1 );
85
85
} else {
86
86
return node ;
87
87
}
@@ -165,7 +165,7 @@ static xmlNodePtr sxe_get_element_by_name(php_sxe_object *sxe, xmlNodePtr node,
165
165
if (sxe -> iter .type == SXE_ITER_NONE ) {
166
166
sxe -> iter .type = SXE_ITER_CHILD ;
167
167
}
168
- node = php_sxe_get_first_node_non_destructive (sxe , node );
168
+ node = php_sxe_get_first_node (sxe , node );
169
169
sxe -> iter .type = orgtype ;
170
170
}
171
171
@@ -251,11 +251,11 @@ static zval *sxe_prop_dim_read(zend_object *object, zval *member, bool elements,
251
251
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
252
252
attribs = 1 ;
253
253
elements = 0 ;
254
- node = php_sxe_get_first_node_non_destructive (sxe , node );
254
+ node = php_sxe_get_first_node (sxe , node );
255
255
attr = (xmlAttrPtr )node ;
256
256
test = sxe -> iter .name != NULL ;
257
257
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
258
- node = php_sxe_get_first_node_non_destructive (sxe , node );
258
+ node = php_sxe_get_first_node (sxe , node );
259
259
attr = node ? node -> properties : NULL ;
260
260
test = 0 ;
261
261
if (!member && node && node -> parent &&
@@ -303,7 +303,7 @@ static zval *sxe_prop_dim_read(zend_object *object, zval *member, bool elements,
303
303
xmlNodePtr mynode = node ;
304
304
305
305
if (sxe -> iter .type == SXE_ITER_CHILD ) {
306
- node = php_sxe_get_first_node_non_destructive (sxe , node );
306
+ node = php_sxe_get_first_node (sxe , node );
307
307
}
308
308
if (sxe -> iter .type == SXE_ITER_NONE ) {
309
309
if (member && Z_LVAL_P (member ) > 0 ) {
@@ -437,12 +437,12 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value,
437
437
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
438
438
attribs = 1 ;
439
439
elements = 0 ;
440
- node = php_sxe_get_first_node_non_destructive (sxe , node );
440
+ node = php_sxe_get_first_node (sxe , node );
441
441
attr = (xmlAttrPtr )node ;
442
442
test = sxe -> iter .name != NULL ;
443
443
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
444
444
mynode = node ;
445
- node = php_sxe_get_first_node_non_destructive (sxe , node );
445
+ node = php_sxe_get_first_node (sxe , node );
446
446
attr = node ? node -> properties : NULL ;
447
447
test = 0 ;
448
448
if (!member && node && node -> parent &&
@@ -688,19 +688,19 @@ static int sxe_prop_dim_exists(zend_object *object, zval *member, int check_empt
688
688
attribs = 0 ;
689
689
elements = 1 ;
690
690
if (sxe -> iter .type == SXE_ITER_CHILD ) {
691
- node = php_sxe_get_first_node_non_destructive (sxe , node );
691
+ node = php_sxe_get_first_node (sxe , node );
692
692
}
693
693
}
694
694
}
695
695
696
696
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
697
697
attribs = 1 ;
698
698
elements = 0 ;
699
- node = php_sxe_get_first_node_non_destructive (sxe , node );
699
+ node = php_sxe_get_first_node (sxe , node );
700
700
attr = (xmlAttrPtr )node ;
701
701
test = sxe -> iter .name != NULL ;
702
702
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
703
- node = php_sxe_get_first_node_non_destructive (sxe , node );
703
+ node = php_sxe_get_first_node (sxe , node );
704
704
attr = node ? node -> properties : NULL ;
705
705
test = 0 ;
706
706
}
@@ -740,7 +740,7 @@ static int sxe_prop_dim_exists(zend_object *object, zval *member, int check_empt
740
740
if (elements ) {
741
741
if (Z_TYPE_P (member ) == IS_LONG ) {
742
742
if (sxe -> iter .type == SXE_ITER_CHILD ) {
743
- node = php_sxe_get_first_node_non_destructive (sxe , node );
743
+ node = php_sxe_get_first_node (sxe , node );
744
744
}
745
745
node = sxe_get_element_by_offset (sxe , Z_LVAL_P (member ), node , NULL );
746
746
} else {
@@ -810,19 +810,19 @@ static void sxe_prop_dim_delete(zend_object *object, zval *member, bool elements
810
810
attribs = 0 ;
811
811
elements = 1 ;
812
812
if (sxe -> iter .type == SXE_ITER_CHILD ) {
813
- node = php_sxe_get_first_node_non_destructive (sxe , node );
813
+ node = php_sxe_get_first_node (sxe , node );
814
814
}
815
815
}
816
816
}
817
817
818
818
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
819
819
attribs = 1 ;
820
820
elements = 0 ;
821
- node = php_sxe_get_first_node_non_destructive (sxe , node );
821
+ node = php_sxe_get_first_node (sxe , node );
822
822
attr = (xmlAttrPtr )node ;
823
823
test = sxe -> iter .name != NULL ;
824
824
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
825
- node = php_sxe_get_first_node_non_destructive (sxe , node );
825
+ node = php_sxe_get_first_node (sxe , node );
826
826
attr = node ? node -> properties : NULL ;
827
827
test = 0 ;
828
828
}
@@ -859,7 +859,7 @@ static void sxe_prop_dim_delete(zend_object *object, zval *member, bool elements
859
859
if (elements ) {
860
860
if (Z_TYPE_P (member ) == IS_LONG ) {
861
861
if (sxe -> iter .type == SXE_ITER_CHILD ) {
862
- node = php_sxe_get_first_node_non_destructive (sxe , node );
862
+ node = php_sxe_get_first_node (sxe , node );
863
863
}
864
864
node = sxe_get_element_by_offset (sxe , Z_LVAL_P (member ), node , NULL );
865
865
if (node ) {
@@ -992,7 +992,7 @@ static int sxe_prop_is_empty(zend_object *object) /* {{{ */
992
992
}
993
993
994
994
if (sxe -> iter .type == SXE_ITER_ELEMENT ) {
995
- node = php_sxe_get_first_node_non_destructive (sxe , node );
995
+ node = php_sxe_get_first_node (sxe , node );
996
996
}
997
997
if (!node || node -> type != XML_ENTITY_DECL ) {
998
998
attr = node ? (xmlAttrPtr )node -> properties : NULL ;
@@ -1006,7 +1006,7 @@ static int sxe_prop_is_empty(zend_object *object) /* {{{ */
1006
1006
}
1007
1007
1008
1008
GET_NODE (sxe , node );
1009
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1009
+ node = php_sxe_get_first_node (sxe , node );
1010
1010
is_empty = 1 ;
1011
1011
ZVAL_UNDEF (& iter_data );
1012
1012
if (node && sxe -> iter .type != SXE_ITER_ATTRLIST ) {
@@ -1101,7 +1101,7 @@ static HashTable *sxe_get_prop_hash(zend_object *object, int is_debug) /* {{{ */
1101
1101
}
1102
1102
if (is_debug || sxe -> iter .type != SXE_ITER_CHILD ) {
1103
1103
if (sxe -> iter .type == SXE_ITER_ELEMENT ) {
1104
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1104
+ node = php_sxe_get_first_node (sxe , node );
1105
1105
}
1106
1106
if (!node || node -> type != XML_ENTITY_DECL ) {
1107
1107
attr = node ? (xmlAttrPtr )node -> properties : NULL ;
@@ -1123,7 +1123,7 @@ static HashTable *sxe_get_prop_hash(zend_object *object, int is_debug) /* {{{ */
1123
1123
}
1124
1124
1125
1125
GET_NODE (sxe , node );
1126
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1126
+ node = php_sxe_get_first_node (sxe , node );
1127
1127
1128
1128
if (node && sxe -> iter .type != SXE_ITER_ATTRLIST ) {
1129
1129
if (node -> type == XML_ATTRIBUTE_NODE ) {
@@ -1282,7 +1282,7 @@ PHP_METHOD(SimpleXMLElement, xpath)
1282
1282
}
1283
1283
1284
1284
GET_NODE (sxe , nodeptr );
1285
- nodeptr = php_sxe_get_first_node_non_destructive (sxe , nodeptr );
1285
+ nodeptr = php_sxe_get_first_node (sxe , nodeptr );
1286
1286
if (!nodeptr ) {
1287
1287
return ;
1288
1288
}
@@ -1391,7 +1391,7 @@ PHP_METHOD(SimpleXMLElement, asXML)
1391
1391
1392
1392
sxe = Z_SXEOBJ_P (ZEND_THIS );
1393
1393
GET_NODE (sxe , node );
1394
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1394
+ node = php_sxe_get_first_node (sxe , node );
1395
1395
1396
1396
if (!node ) {
1397
1397
RETURN_FALSE ;
@@ -1514,7 +1514,7 @@ PHP_METHOD(SimpleXMLElement, getNamespaces)
1514
1514
1515
1515
sxe = Z_SXEOBJ_P (ZEND_THIS );
1516
1516
GET_NODE (sxe , node );
1517
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1517
+ node = php_sxe_get_first_node (sxe , node );
1518
1518
1519
1519
if (node ) {
1520
1520
if (node -> type == XML_ELEMENT_NODE ) {
@@ -1599,7 +1599,7 @@ PHP_METHOD(SimpleXMLElement, children)
1599
1599
}
1600
1600
1601
1601
GET_NODE (sxe , node );
1602
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1602
+ node = php_sxe_get_first_node (sxe , node );
1603
1603
if (!node ) {
1604
1604
return ;
1605
1605
}
@@ -1623,7 +1623,7 @@ PHP_METHOD(SimpleXMLElement, getName)
1623
1623
sxe = Z_SXEOBJ_P (ZEND_THIS );
1624
1624
1625
1625
GET_NODE (sxe , node );
1626
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1626
+ node = php_sxe_get_first_node (sxe , node );
1627
1627
if (node ) {
1628
1628
namelen = xmlStrlen (node -> name );
1629
1629
RETURN_STRINGL ((char * )node -> name , namelen );
@@ -1648,7 +1648,7 @@ PHP_METHOD(SimpleXMLElement, attributes)
1648
1648
1649
1649
sxe = Z_SXEOBJ_P (ZEND_THIS );
1650
1650
GET_NODE (sxe , node );
1651
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1651
+ node = php_sxe_get_first_node (sxe , node );
1652
1652
if (!node ) {
1653
1653
return ;
1654
1654
}
@@ -1689,7 +1689,7 @@ PHP_METHOD(SimpleXMLElement, addChild)
1689
1689
return ;
1690
1690
}
1691
1691
1692
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1692
+ node = php_sxe_get_first_node (sxe , node );
1693
1693
1694
1694
if (node == NULL ) {
1695
1695
php_error_docref (NULL , E_WARNING , "Cannot add child. Parent is not a permanent member of the XML tree" );
@@ -1749,7 +1749,7 @@ PHP_METHOD(SimpleXMLElement, addAttribute)
1749
1749
sxe = Z_SXEOBJ_P (ZEND_THIS );
1750
1750
GET_NODE (sxe , node );
1751
1751
1752
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1752
+ node = php_sxe_get_first_node (sxe , node );
1753
1753
1754
1754
if (node && node -> type != XML_ELEMENT_NODE ) {
1755
1755
node = node -> parent ;
@@ -1842,7 +1842,7 @@ static int sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type)
1842
1842
sxe = php_sxe_fetch_object (readobj );
1843
1843
1844
1844
if (type == _IS_BOOL ) {
1845
- node = php_sxe_get_first_node_non_destructive (sxe , NULL );
1845
+ node = php_sxe_get_first_node (sxe , NULL );
1846
1846
if (node ) {
1847
1847
ZVAL_TRUE (writeobj );
1848
1848
} else {
@@ -1852,7 +1852,7 @@ static int sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type)
1852
1852
}
1853
1853
1854
1854
if (sxe -> iter .type != SXE_ITER_NONE ) {
1855
- node = php_sxe_get_first_node_non_destructive (sxe , NULL );
1855
+ node = php_sxe_get_first_node (sxe , NULL );
1856
1856
if (node ) {
1857
1857
contents = xmlNodeListGetString ((xmlDocPtr ) sxe -> document -> ptr , node -> children , 1 );
1858
1858
}
@@ -2600,7 +2600,7 @@ void *simplexml_export_node(zval *object) /* {{{ */
2600
2600
2601
2601
sxe = Z_SXEOBJ_P (object );
2602
2602
GET_NODE (sxe , node );
2603
- return php_sxe_get_first_node_non_destructive (sxe , node );
2603
+ return php_sxe_get_first_node (sxe , node );
2604
2604
}
2605
2605
/* }}} */
2606
2606
0 commit comments