@@ -77,10 +77,10 @@ static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE
77
77
}
78
78
/* }}} */
79
79
80
- static xmlNodePtr php_sxe_get_first_node_non_destructive (php_sxe_object * sxe , xmlNodePtr node )
80
+ static xmlNodePtr php_sxe_get_first_node (php_sxe_object * sxe , xmlNodePtr node )
81
81
{
82
82
if (sxe && sxe -> iter .type != SXE_ITER_NONE ) {
83
- return php_sxe_reset_iterator_no_clear_iter_data (sxe , false );
83
+ return php_sxe_reset_iterator (sxe , 1 );
84
84
} else {
85
85
return node ;
86
86
}
@@ -163,7 +163,7 @@ static xmlNodePtr sxe_get_element_by_name(php_sxe_object *sxe, xmlNodePtr node,
163
163
if (sxe -> iter .type == SXE_ITER_NONE ) {
164
164
sxe -> iter .type = SXE_ITER_CHILD ;
165
165
}
166
- node = php_sxe_get_first_node_non_destructive (sxe , node );
166
+ node = php_sxe_get_first_node (sxe , node );
167
167
sxe -> iter .type = orgtype ;
168
168
}
169
169
@@ -238,11 +238,11 @@ static zval *sxe_prop_dim_read(zend_object *object, zval *member, bool elements,
238
238
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
239
239
attribs = 1 ;
240
240
elements = 0 ;
241
- node = php_sxe_get_first_node_non_destructive (sxe , node );
241
+ node = php_sxe_get_first_node (sxe , node );
242
242
attr = (xmlAttrPtr )node ;
243
243
test = sxe -> iter .name != NULL ;
244
244
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
245
- node = php_sxe_get_first_node_non_destructive (sxe , node );
245
+ node = php_sxe_get_first_node (sxe , node );
246
246
attr = node ? node -> properties : NULL ;
247
247
test = 0 ;
248
248
if (!member && node && node -> parent &&
@@ -290,7 +290,7 @@ static zval *sxe_prop_dim_read(zend_object *object, zval *member, bool elements,
290
290
xmlNodePtr mynode = node ;
291
291
292
292
if (sxe -> iter .type == SXE_ITER_CHILD ) {
293
- node = php_sxe_get_first_node_non_destructive (sxe , node );
293
+ node = php_sxe_get_first_node (sxe , node );
294
294
}
295
295
if (sxe -> iter .type == SXE_ITER_NONE ) {
296
296
if (member && Z_LVAL_P (member ) > 0 ) {
@@ -426,12 +426,12 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value,
426
426
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
427
427
attribs = 1 ;
428
428
elements = 0 ;
429
- node = php_sxe_get_first_node_non_destructive (sxe , node );
429
+ node = php_sxe_get_first_node (sxe , node );
430
430
attr = (xmlAttrPtr )node ;
431
431
test = sxe -> iter .name != NULL ;
432
432
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
433
433
mynode = node ;
434
- node = php_sxe_get_first_node_non_destructive (sxe , node );
434
+ node = php_sxe_get_first_node (sxe , node );
435
435
attr = node ? node -> properties : NULL ;
436
436
test = 0 ;
437
437
if (!member && node && node -> parent &&
@@ -677,19 +677,19 @@ static int sxe_prop_dim_exists(zend_object *object, zval *member, int check_empt
677
677
attribs = 0 ;
678
678
elements = 1 ;
679
679
if (sxe -> iter .type == SXE_ITER_CHILD ) {
680
- node = php_sxe_get_first_node_non_destructive (sxe , node );
680
+ node = php_sxe_get_first_node (sxe , node );
681
681
}
682
682
}
683
683
}
684
684
685
685
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
686
686
attribs = 1 ;
687
687
elements = 0 ;
688
- node = php_sxe_get_first_node_non_destructive (sxe , node );
688
+ node = php_sxe_get_first_node (sxe , node );
689
689
attr = (xmlAttrPtr )node ;
690
690
test = sxe -> iter .name != NULL ;
691
691
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
692
- node = php_sxe_get_first_node_non_destructive (sxe , node );
692
+ node = php_sxe_get_first_node (sxe , node );
693
693
attr = node ? node -> properties : NULL ;
694
694
test = 0 ;
695
695
}
@@ -729,7 +729,7 @@ static int sxe_prop_dim_exists(zend_object *object, zval *member, int check_empt
729
729
if (elements ) {
730
730
if (Z_TYPE_P (member ) == IS_LONG ) {
731
731
if (sxe -> iter .type == SXE_ITER_CHILD ) {
732
- node = php_sxe_get_first_node_non_destructive (sxe , node );
732
+ node = php_sxe_get_first_node (sxe , node );
733
733
}
734
734
node = sxe_get_element_by_offset (sxe , Z_LVAL_P (member ), node , NULL );
735
735
} else {
@@ -801,19 +801,19 @@ static void sxe_prop_dim_delete(zend_object *object, zval *member, bool elements
801
801
attribs = 0 ;
802
802
elements = 1 ;
803
803
if (sxe -> iter .type == SXE_ITER_CHILD ) {
804
- node = php_sxe_get_first_node_non_destructive (sxe , node );
804
+ node = php_sxe_get_first_node (sxe , node );
805
805
}
806
806
}
807
807
}
808
808
809
809
if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
810
810
attribs = 1 ;
811
811
elements = 0 ;
812
- node = php_sxe_get_first_node_non_destructive (sxe , node );
812
+ node = php_sxe_get_first_node (sxe , node );
813
813
attr = (xmlAttrPtr )node ;
814
814
test = sxe -> iter .name != NULL ;
815
815
} else if (sxe -> iter .type != SXE_ITER_CHILD ) {
816
- node = php_sxe_get_first_node_non_destructive (sxe , node );
816
+ node = php_sxe_get_first_node (sxe , node );
817
817
attr = node ? node -> properties : NULL ;
818
818
test = 0 ;
819
819
}
@@ -850,7 +850,7 @@ static void sxe_prop_dim_delete(zend_object *object, zval *member, bool elements
850
850
if (elements ) {
851
851
if (Z_TYPE_P (member ) == IS_LONG ) {
852
852
if (sxe -> iter .type == SXE_ITER_CHILD ) {
853
- node = php_sxe_get_first_node_non_destructive (sxe , node );
853
+ node = php_sxe_get_first_node (sxe , node );
854
854
}
855
855
node = sxe_get_element_by_offset (sxe , Z_LVAL_P (member ), node , NULL );
856
856
if (node ) {
@@ -983,7 +983,7 @@ static int sxe_prop_is_empty(zend_object *object) /* {{{ */
983
983
}
984
984
985
985
if (sxe -> iter .type == SXE_ITER_ELEMENT ) {
986
- node = php_sxe_get_first_node_non_destructive (sxe , node );
986
+ node = php_sxe_get_first_node (sxe , node );
987
987
}
988
988
if (!node || node -> type != XML_ENTITY_DECL ) {
989
989
attr = node ? (xmlAttrPtr )node -> properties : NULL ;
@@ -997,7 +997,7 @@ static int sxe_prop_is_empty(zend_object *object) /* {{{ */
997
997
}
998
998
999
999
GET_NODE (sxe , node );
1000
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1000
+ node = php_sxe_get_first_node (sxe , node );
1001
1001
is_empty = 1 ;
1002
1002
ZVAL_UNDEF (& iter_data );
1003
1003
if (node && sxe -> iter .type != SXE_ITER_ATTRLIST ) {
@@ -1092,7 +1092,7 @@ static HashTable *sxe_get_prop_hash(zend_object *object, int is_debug) /* {{{ */
1092
1092
}
1093
1093
if (is_debug || sxe -> iter .type != SXE_ITER_CHILD ) {
1094
1094
if (sxe -> iter .type == SXE_ITER_ELEMENT ) {
1095
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1095
+ node = php_sxe_get_first_node (sxe , node );
1096
1096
}
1097
1097
if (!node || node -> type != XML_ENTITY_DECL ) {
1098
1098
attr = node ? (xmlAttrPtr )node -> properties : NULL ;
@@ -1114,7 +1114,7 @@ static HashTable *sxe_get_prop_hash(zend_object *object, int is_debug) /* {{{ */
1114
1114
}
1115
1115
1116
1116
GET_NODE (sxe , node );
1117
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1117
+ node = php_sxe_get_first_node (sxe , node );
1118
1118
1119
1119
if (node && sxe -> iter .type != SXE_ITER_ATTRLIST ) {
1120
1120
if (node -> type == XML_ATTRIBUTE_NODE ) {
@@ -1273,7 +1273,7 @@ PHP_METHOD(SimpleXMLElement, xpath)
1273
1273
}
1274
1274
1275
1275
GET_NODE (sxe , nodeptr );
1276
- nodeptr = php_sxe_get_first_node_non_destructive (sxe , nodeptr );
1276
+ nodeptr = php_sxe_get_first_node (sxe , nodeptr );
1277
1277
if (!nodeptr ) {
1278
1278
return ;
1279
1279
}
@@ -1382,7 +1382,7 @@ PHP_METHOD(SimpleXMLElement, asXML)
1382
1382
1383
1383
sxe = Z_SXEOBJ_P (ZEND_THIS );
1384
1384
GET_NODE (sxe , node );
1385
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1385
+ node = php_sxe_get_first_node (sxe , node );
1386
1386
1387
1387
if (!node ) {
1388
1388
RETURN_FALSE ;
@@ -1505,7 +1505,7 @@ PHP_METHOD(SimpleXMLElement, getNamespaces)
1505
1505
1506
1506
sxe = Z_SXEOBJ_P (ZEND_THIS );
1507
1507
GET_NODE (sxe , node );
1508
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1508
+ node = php_sxe_get_first_node (sxe , node );
1509
1509
1510
1510
if (node ) {
1511
1511
if (node -> type == XML_ELEMENT_NODE ) {
@@ -1590,7 +1590,7 @@ PHP_METHOD(SimpleXMLElement, children)
1590
1590
}
1591
1591
1592
1592
GET_NODE (sxe , node );
1593
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1593
+ node = php_sxe_get_first_node (sxe , node );
1594
1594
if (!node ) {
1595
1595
return ;
1596
1596
}
@@ -1614,7 +1614,7 @@ PHP_METHOD(SimpleXMLElement, getName)
1614
1614
sxe = Z_SXEOBJ_P (ZEND_THIS );
1615
1615
1616
1616
GET_NODE (sxe , node );
1617
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1617
+ node = php_sxe_get_first_node (sxe , node );
1618
1618
if (node ) {
1619
1619
namelen = xmlStrlen (node -> name );
1620
1620
RETURN_STRINGL ((char * )node -> name , namelen );
@@ -1639,7 +1639,7 @@ PHP_METHOD(SimpleXMLElement, attributes)
1639
1639
1640
1640
sxe = Z_SXEOBJ_P (ZEND_THIS );
1641
1641
GET_NODE (sxe , node );
1642
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1642
+ node = php_sxe_get_first_node (sxe , node );
1643
1643
if (!node ) {
1644
1644
return ;
1645
1645
}
@@ -1682,7 +1682,7 @@ PHP_METHOD(SimpleXMLElement, addChild)
1682
1682
return ;
1683
1683
}
1684
1684
1685
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1685
+ node = php_sxe_get_first_node (sxe , node );
1686
1686
1687
1687
if (node == NULL ) {
1688
1688
php_error_docref (NULL , E_WARNING , "Cannot add child. Parent is not a permanent member of the XML tree" );
@@ -1742,7 +1742,7 @@ PHP_METHOD(SimpleXMLElement, addAttribute)
1742
1742
sxe = Z_SXEOBJ_P (ZEND_THIS );
1743
1743
GET_NODE (sxe , node );
1744
1744
1745
- node = php_sxe_get_first_node_non_destructive (sxe , node );
1745
+ node = php_sxe_get_first_node (sxe , node );
1746
1746
1747
1747
if (node && node -> type != XML_ELEMENT_NODE ) {
1748
1748
node = node -> parent ;
@@ -1835,7 +1835,7 @@ static zend_result sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int
1835
1835
sxe = php_sxe_fetch_object (readobj );
1836
1836
1837
1837
if (type == _IS_BOOL ) {
1838
- node = php_sxe_get_first_node_non_destructive (sxe , NULL );
1838
+ node = php_sxe_get_first_node (sxe , NULL );
1839
1839
if (node ) {
1840
1840
ZVAL_TRUE (writeobj );
1841
1841
} else {
@@ -1845,7 +1845,7 @@ static zend_result sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int
1845
1845
}
1846
1846
1847
1847
if (sxe -> iter .type != SXE_ITER_NONE ) {
1848
- node = php_sxe_get_first_node_non_destructive (sxe , NULL );
1848
+ node = php_sxe_get_first_node (sxe , NULL );
1849
1849
if (node ) {
1850
1850
contents = xmlNodeListGetString ((xmlDocPtr ) sxe -> document -> ptr , node -> children , 1 );
1851
1851
}
@@ -2593,7 +2593,7 @@ void *simplexml_export_node(zval *object) /* {{{ */
2593
2593
2594
2594
sxe = Z_SXEOBJ_P (object );
2595
2595
GET_NODE (sxe , node );
2596
- return php_sxe_get_first_node_non_destructive (sxe , node );
2596
+ return php_sxe_get_first_node (sxe , node );
2597
2597
}
2598
2598
/* }}} */
2599
2599
0 commit comments