[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2009-06-10 Thread Hannes Magnusson
bjori   Wed Jun 10 14:28:06 2009 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fix extension loading order
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.276r2=1.277diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.276 
php-src/ext/simplexml/simplexml.c:1.277
--- php-src/ext/simplexml/simplexml.c:1.276 Mon May 25 14:32:14 2009
+++ php-src/ext/simplexml/simplexml.c   Wed Jun 10 14:28:06 2009
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.276 2009/05/25 14:32:14 felipe Exp $ */
+/* $Id: simplexml.c,v 1.277 2009/06/10 14:28:06 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -2532,6 +2532,7 @@
 
 static const zend_module_dep simplexml_deps[] = { /* {{{ */
ZEND_MOD_REQUIRED(libxml)
+   ZEND_MOD_REQUIRED(spl)
{NULL, NULL, NULL}
 };
 /* }}} */
@@ -2616,7 +2617,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.276 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.277 $);
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 simplexml.c /ext/simplexml/tests bug46048.phpt

2009-02-03 Thread David Coallier
davidc  Wed Feb  4 00:07:27 2009 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug46048.phpt 
  Log:
  - MFB (Fixed Bug #46048: SimpleXML top-level @attributes not in iterator).
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.271r2=1.272diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.271 
php-src/ext/simplexml/simplexml.c:1.272
--- php-src/ext/simplexml/simplexml.c:1.271 Wed Dec 31 11:12:35 2008
+++ php-src/ext/simplexml/simplexml.c   Wed Feb  4 00:07:27 2009
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.271 2008/12/31 11:12:35 sebastian Exp $ */
+/* $Id: simplexml.c,v 1.272 2009/02/04 00:07:27 davidc Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1081,7 +1081,7 @@
if (!node) {
return rv;
}
-   if (is_debug) {
+   if (is_debug || sxe-iter.type != SXE_ITER_CHILD) {
if (sxe-iter.type == SXE_ITER_ELEMENT) {
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
}
@@ -2634,7 +2634,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.271 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.272 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug46048.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug46048.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug46048.phpt:1.2
--- /dev/null   Wed Feb  4 00:07:27 2009
+++ php-src/ext/simplexml/tests/bug46048.phpt   Wed Feb  4 00:07:27 2009
@@ -0,0 +1,24 @@
+--TEST--
+Bug #46048 (SimpleXML top-level @attributes not part of iterator)
+--FILE--
+?php
+$xml = '
+data id=1
+keyvalue/key
+/data
+';
+$obj = simplexml_load_string($xml);
+print_r(get_object_vars($obj));
+echo Done\n;
+?
+--EXPECT-- 
+Array
+(
+[...@attributes] = Array
+(
+[id] = 1
+)
+
+[key] = value
+)
+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 simplexml.c

2008-10-20 Thread Rob Richards
rrichards   Mon Oct 20 19:28:36 2008 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #46323 (compilation of simplexml for NetWare breaks)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.262r2=1.263diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.262 
php-src/ext/simplexml/simplexml.c:1.263
--- php-src/ext/simplexml/simplexml.c:1.262 Thu Oct 16 11:42:20 2008
+++ php-src/ext/simplexml/simplexml.c   Mon Oct 20 19:28:36 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.262 2008/10/16 11:42:20 indeyets Exp $ */
+/* $Id: simplexml.c,v 1.263 2008/10/20 19:28:36 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1291,7 +1291,7 @@
if (nodeptr-type == XML_TEXT_NODE) {
_node_as_zval(sxe, nodeptr-parent, value, 
SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
} else if (nodeptr-type == XML_ATTRIBUTE_NODE) {
-   _node_as_zval(sxe, nodeptr-parent, value, 
SXE_ITER_ATTRLIST, (char*)nodeptr-name, nodeptr-ns ? nodeptr-ns-href : 
NULL, 0 TSRMLS_CC);
+   _node_as_zval(sxe, nodeptr-parent, value, 
SXE_ITER_ATTRLIST, (char*)nodeptr-name, nodeptr-ns ? (xmlChar 
*)nodeptr-ns-href : NULL, 0 TSRMLS_CC);
} else {
_node_as_zval(sxe, nodeptr, value, 
SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
}
@@ -2644,7 +2644,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.262 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.263 $);
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 simplexml.c /ext/simplexml/tests bug46047.phpt

2008-09-11 Thread Rob Richards
rrichards   Thu Sep 11 14:20:30 2008 UTC

  Added files: 
/php-src/ext/simplexml/testsbug46047.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #46047 (SimpleXML converts empty nodes into object with nested array)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.260r2=1.261diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.260 
php-src/ext/simplexml/simplexml.c:1.261
--- php-src/ext/simplexml/simplexml.c:1.260 Wed Sep 10 16:28:20 2008
+++ php-src/ext/simplexml/simplexml.c   Thu Sep 11 14:20:30 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.260 2008/09/10 16:28:20 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.261 2008/09/11 14:20:30 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1142,13 +1142,17 @@
SKIP_TEXT(node);
} else {
if (node-type == XML_TEXT_NODE) {
-   xmlChar *tmp;
-
-   MAKE_STD_ZVAL(value);
-   tmp = xmlNodeListGetString(node-doc, 
node, 1);
-   ZVAL_XML_STRING(value, (char *)tmp, 
ZSTR_DUPLICATE);
-   xmlFree(tmp);
-   zend_hash_next_index_insert(rv, value, 
sizeof(zval *), NULL);
+   const xmlChar *cur = node-content;
+   
+   if (*cur != 0) {
+   xmlChar *tmp;
+   
+   MAKE_STD_ZVAL(value);
+   tmp = 
xmlNodeListGetString(node-doc, node, 1);
+   ZVAL_XML_STRING(value, (char 
*)tmp, ZSTR_DUPLICATE);
+   xmlFree(tmp);
+   zend_hash_next_index_insert(rv, 
value, sizeof(zval *), NULL);
+   }
goto next_iter;
}
}
@@ -2640,7 +2644,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.260 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.261 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug46047.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug46047.phpt
+++ php-src/ext/simplexml/tests/bug46047.phpt
--TEST--
Bug #46047 (SimpleXML converts empty nodes into object with nested array)
--FILE--
?php
$xml = new SimpleXMLElement('foobar![CDATA[]]/barbaz//foo', 
  LIBXML_NOCDATA);
print_r($xml);

$xml = new SimpleXMLElement('foobar/barbaz//foo');
print_r($xml);

$xml = new SimpleXMLElement('foobar/baz//foo');
print_r($xml);
?
--EXPECTF--
SimpleXMLElement Object
(
[bar] = SimpleXMLElement Object
(
)

[baz] = SimpleXMLElement Object
(
)

)
SimpleXMLElement Object
(
[bar] = SimpleXMLElement Object
(
)

[baz] = SimpleXMLElement Object
(
)

)
SimpleXMLElement Object
(
[bar] = SimpleXMLElement Object
(
)

[baz] = SimpleXMLElement Object
(
)

)


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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug45553.phpt

2008-09-10 Thread Rob Richards
rrichards   Wed Sep 10 11:20:35 2008 UTC

  Added files: 
/php-src/ext/simplexml/testsbug45553.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #45553 (Using XPath for attributes with a namespace does not work)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.258r2=1.259diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.258 
php-src/ext/simplexml/simplexml.c:1.259
--- php-src/ext/simplexml/simplexml.c:1.258 Fri Aug  8 22:06:42 2008
+++ php-src/ext/simplexml/simplexml.c   Wed Sep 10 11:20:35 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.258 2008/08/08 22:06:42 colder Exp $ */
+/* $Id: simplexml.c,v 1.259 2008/09/10 11:20:35 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1287,7 +1287,7 @@
if (nodeptr-type == XML_TEXT_NODE) {
_node_as_zval(sxe, nodeptr-parent, value, 
SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
} else if (nodeptr-type == XML_ATTRIBUTE_NODE) {
-   _node_as_zval(sxe, nodeptr-parent, value, 
SXE_ITER_ATTRLIST, (char *)nodeptr-name, NULL, 0 TSRMLS_CC);
+   _node_as_zval(sxe, nodeptr-parent, value, 
SXE_ITER_ATTRLIST, (char*)nodeptr-name, nodeptr-ns ? nodeptr-ns-href : 
NULL, 0 TSRMLS_CC);
} else {
_node_as_zval(sxe, nodeptr, value, 
SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
}
@@ -2640,7 +2640,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.258 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.259 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug45553.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug45553.phpt
+++ php-src/ext/simplexml/tests/bug45553.phpt
--TEST--
Bug #45553 (Using XPath to return values for attributes with a namespace does 
not work)
--FILE--
?php
$xml =XML
xml xmlns:a=http://a;
data a:label=I am A label=I am Nothingtest1/data
a:data a:label=I am a:A label=I am a:Nothingtest2/a:data
/xml
XML;

$x = simplexml_load_string($xml);
$x-registerXPathNamespace(a, http://a;);

$atts = $x-xpath(/xml/data/@a:label);
echo $atts[0] . \n;
$atts = $x-xpath(/xml/a:data);
echo $atts[0]-attributes() . \n;
$atts = $x-xpath(/xml/a:data/@a:label);
echo $atts[0] . \n;
$atts = $x-xpath(/xml/a:data/@label);
echo $atts[0] . \n;
$atts = $x-xpath(/xml/data/@label);
echo $atts[0] . \n;
?
--EXPECTF--
I am A
I am a:Nothing
I am a:A
I am a:Nothing
I am Nothing


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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug46003.phpt

2008-09-10 Thread Rob Richards
rrichards   Wed Sep 10 16:28:20 2008 UTC

  Added files: 
/php-src/ext/simplexml/testsbug46003.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #46003 (isset on nonexisting node return unexpected results)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.259r2=1.260diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.259 
php-src/ext/simplexml/simplexml.c:1.260
--- php-src/ext/simplexml/simplexml.c:1.259 Wed Sep 10 11:20:35 2008
+++ php-src/ext/simplexml/simplexml.c   Wed Sep 10 16:28:20 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.259 2008/09/10 11:20:35 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.260 2008/09/10 16:28:20 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -829,7 +829,7 @@
while (node) {
xmlNodePtr nnext;
nnext = node-next;
-   if (!xmlStrcmp(node-name, (xmlChar 
*)Z_STRVAL_P(member))) {
+   if ((node-type == XML_ELEMENT_NODE)  
!xmlStrcmp(node-name, (xmlChar *)Z_STRVAL_P(member))) {
break;
}
node = nnext;
@@ -2640,7 +2640,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.259 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.260 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug46003.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug46003.phpt
+++ php-src/ext/simplexml/tests/bug46003.phpt
--TEST--
Bug #46003 (isset on nonexisting nodes return unexpected results)
--FILE--
?php
$xml =XML
r
  pTest/p
  o d='h'
xx rr='info' /
yy rr='data' /
  /o
/r
XML;

$x = simplexml_load_string($xml);

var_dump(isset($x-p));
var_dump(isset($x-p-o));
var_dump(isset($x-o-yy));
var_dump(isset($x-o-zz));
var_dump(isset($x-o-text));
var_dump(isset($x-o-xx));
?
--EXPECTF--
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
bool(true)


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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2008-06-27 Thread Felipe Pena
felipe  Fri Jun 27 15:47:21 2008 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - MFB: Added arginfo
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.255r2=1.256diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.255 
php-src/ext/simplexml/simplexml.c:1.256
--- php-src/ext/simplexml/simplexml.c:1.255 Fri May 23 15:46:24 2008
+++ php-src/ext/simplexml/simplexml.c   Fri Jun 27 15:47:21 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.255 2008/05/23 15:46:24 iliaa Exp $ */
+/* $Id: simplexml.c,v 1.256 2008/06/27 15:47:21 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -2463,10 +2463,36 @@
 }
 /* }}} */
 
+/* {{{ arginfo */
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexml_load_file, 0, 0, 1)
+   ZEND_ARG_INFO(0, filename)
+   ZEND_ARG_INFO(0, class_name)
+   ZEND_ARG_INFO(0, options)
+   ZEND_ARG_INFO(0, ns)
+   ZEND_ARG_INFO(0, is_prefix)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexml_load_string, 0, 0, 1)
+   ZEND_ARG_INFO(0, data)
+   ZEND_ARG_INFO(0, class_name)
+   ZEND_ARG_INFO(0, options)
+   ZEND_ARG_INFO(0, ns)
+   ZEND_ARG_INFO(0, is_prefix)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexml_import_dom, 0, 0, 1)
+   ZEND_ARG_INFO(0, node)
+   ZEND_ARG_INFO(0, class_name)
+ZEND_END_ARG_INFO()
+/* }}} */
+
 const zend_function_entry simplexml_functions[] = { /* {{{ */
-   PHP_FE(simplexml_load_file, NULL)
-   PHP_FE(simplexml_load_string, NULL)
-   PHP_FE(simplexml_import_dom, NULL)
+   PHP_FE(simplexml_load_file, arginfo_simplexml_load_file)
+   PHP_FE(simplexml_load_string,   arginfo_simplexml_load_string)
+   PHP_FE(simplexml_import_dom,arginfo_simplexml_import_dom)
{NULL, NULL, NULL}
 };
 /* }}} */
@@ -2560,7 +2586,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.255 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.256 $);
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 simplexml.c

2008-05-23 Thread Ilia Alshanetsky
iliaa   Fri May 23 15:46:24 2008 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  
  MFB:When dumping entire document to file via asXml() don't lose the encoding
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.254r2=1.255diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.254 
php-src/ext/simplexml/simplexml.c:1.255
--- php-src/ext/simplexml/simplexml.c:1.254 Sat May  3 15:09:24 2008
+++ php-src/ext/simplexml/simplexml.c   Fri May 23 15:46:24 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.254 2008/05/03 15:09:24 colder Exp $ */
+/* $Id: simplexml.c,v 1.255 2008/05/23 15:46:24 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1392,7 +1392,7 @@
 
if (node) {
if (node-parent  (XML_DOCUMENT_NODE == node-parent-type)) {
-   xmlDocDumpMemory((xmlDocPtr) sxe-document-ptr, 
strval, strval_len);
+   xmlDocDumpMemoryEnc((xmlDocPtr) sxe-document-ptr, 
strval, strval_len, ((xmlDocPtr) sxe-document-ptr)-encoding);
RETVAL_STRINGL((char *)strval, strval_len, 1);
xmlFree(strval);
} else {
@@ -2560,7 +2560,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.254 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.255 $);
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 simplexml.c /ext/simplexml/tests 035.phpt

2008-05-03 Thread Etienne Kneuss
colder  Sat May  3 15:09:24 2008 UTC

  Added files: 
/php-src/ext/simplexml/tests035.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fix #44484 (define SimpleXMLElement::__toString())
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.253r2=1.254diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.253 
php-src/ext/simplexml/simplexml.c:1.254
--- php-src/ext/simplexml/simplexml.c:1.253 Thu Mar 20 16:46:55 2008
+++ php-src/ext/simplexml/simplexml.c   Sat May  3 15:09:24 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.253 2008/03/20 16:46:55 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.254 2008/05/03 15:09:24 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1851,6 +1851,23 @@
 }
 /* }}} */
 
+/* {{{ proto object SimpleXMLElement::__toString() U
+   Returns the string content */
+SXE_METHOD(__toString)
+{
+   zval   *result;
+
+   ALLOC_INIT_ZVAL(result);
+
+   if (sxe_object_cast(getThis(), result, IS_STRING, NULL TSRMLS_CC) == 
SUCCESS) {
+   RETURN_ZVAL(result, 1, 1);
+   } else {
+   zval_ptr_dtor(result);
+   RETURN_EMPTY_TEXT();
+   }
+}
+/* }}} */
+
 static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
 {
php_sxe_object  *sxe;
@@ -2494,6 +2511,7 @@
SXE_ME(getName,NULL, ZEND_ACC_PUBLIC)
SXE_ME(addChild,   NULL, ZEND_ACC_PUBLIC)
SXE_ME(addAttribute,   NULL, ZEND_ACC_PUBLIC)
+   SXE_ME(__toString, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
 };
 /* }}} */
@@ -2542,7 +2560,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.253 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.254 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/035.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/035.phpt
+++ php-src/ext/simplexml/tests/035.phpt
--TEST--
SimpleXML: __toString
--SKIPIF--
?php if (!extension_loaded(simplexml)) print skip; ?
--FILE--
?php
$string = '?xml version=1.0?
foobar
   pBlah 1/p
   pBlah 2/p
   pBlah 3/p
   ttBlah 4/tt
/bar/foo
';
$foo = simplexml_load_string($string);
$p = $foo-bar-p;
echo $p.\n;
echo $p-__toString().\n;
?
==Done==
--EXPECT--
Blah 1
Blah 1
==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 simplexml.c /ext/simplexml/tests bug44478.phpt

2008-03-20 Thread Rob Richards
rrichards   Thu Mar 20 16:46:55 2008 UTC

  Added files: 
/php-src/ext/simplexml/testsbug44478.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #44478 (Inconsistent behaviour when assigning new nodes)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.252r2=1.253diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.252 
php-src/ext/simplexml/simplexml.c:1.253
--- php-src/ext/simplexml/simplexml.c:1.252 Thu Jan 31 21:58:09 2008
+++ php-src/ext/simplexml/simplexml.c   Thu Mar 20 16:46:55 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.252 2008/01/31 21:58:09 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.253 2008/03/20 16:46:55 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -434,19 +434,12 @@
convert_to_string_with_converter(value, UG(utf8_conv));
/* break missing intentionally */
case IS_STRING:
-   if (node-type == XML_ATTRIBUTE_NODE) {
-   buffer = xmlEncodeEntitiesReentrant(node-doc, 
(xmlChar *)Z_STRVAL_P(value));
-   buffer_len = xmlStrlen(buffer);
-   } else {
-   buffer = (xmlChar *)Z_STRVAL_P(value);
-   buffer_len = Z_STRLEN_P(value);
-   }
+   buffer = xmlEncodeEntitiesReentrant(node-doc, (xmlChar 
*)Z_STRVAL_P(value));
+   buffer_len = xmlStrlen(buffer);
/* check for NULL buffer in case of memory error in 
xmlEncodeEntitiesReentrant */
if (buffer) {
xmlNodeSetContentLen(node, buffer, buffer_len);
-   if (node-type == XML_ATTRIBUTE_NODE) {
-   xmlFree(buffer);
-   }
+   xmlFree(buffer);
}
if (value == value_copy) {
zval_dtor(value);
@@ -2549,7 +2542,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.252 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.253 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug44478.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug44478.phpt
+++ php-src/ext/simplexml/tests/bug44478.phpt
--TEST--
Bug #44478 (Inconsistent behaviour when assigning new nodes)
--FILE--
?php
$xml_element = new simpleXMLElement('root/root');
$xml_element-node1 = 'a #38; b';
print $xml_element-node1.\n;
$xml_element-node1 = 'a #38; b';
print $xml_element-node1.\n;
$xml_element-addChild('node2','a #38; b');
print $xml_element-node2.\n;
$xml_element-node2 = 'a  b';
print $xml_element-node2.\n;

print $xml_element-asXML();

?
--EXPECTF--
a #38; b
a #38; b
a  b
a  b
?xml version=1.0?
rootnode1a amp;#38; b/node1node2a amp; b/node2/root



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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug42369.phpt

2008-01-31 Thread Rob Richards
rrichards   Thu Jan 31 21:58:09 2008 UTC

  Added files: 
/php-src/ext/simplexml/testsbug42369.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #42369 (Implicit conversion to string leaks memory)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.251r2=1.252diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.251 
php-src/ext/simplexml/simplexml.c:1.252
--- php-src/ext/simplexml/simplexml.c:1.251 Tue Jan 29 09:59:53 2008
+++ php-src/ext/simplexml/simplexml.c   Thu Jan 31 21:58:09 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.251 2008/01/29 09:59:53 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.252 2008/01/31 21:58:09 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1844,6 +1844,11 @@
}
}
 
+   if (readobj == writeobj) {
+   INIT_PZVAL(writeobj);
+   zval_dtor(readobj);
+   }
+
rv = cast_object(writeobj, type, (char *)contents, extra TSRMLS_CC);
 
if (contents) {
@@ -2544,7 +2549,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.251 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.252 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug42369.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug42369.phpt
+++ php-src/ext/simplexml/tests/bug42369.phpt
--TEST--
Bug #42369 (Implicit conversion to string leaks memory)
--SKIPIF--
?php if (!extension_loaded('simplexml')) echo 'skip simplexml extension is not 
loaded'; 
--FILE--
?php
$xml = '?xml version=1.0 encoding=utf-8?';
$x = simplexml_load_string($xml . qxfoo/x/q);

echo 'explicit conversion' . PHP_EOL;
for ($i = 0; $i  10; $i++) {
md5(strval($x-x));
}

echo 'no conversion' . PHP_EOL;
for ($i = 0; $i  10; $i++) {
md5($x-x);
}

echo 'done' . PHP_EOL;
?
--EXPECT--
explicit conversion
no conversion
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 simplexml.c ZendEngine2 zend_gc.c zend_gc.h ZendEngine2/tests bug43918.phpt

2008-01-29 Thread Dmitry Stogov
dmitry  Tue Jan 29 09:59:53 2008 UTC

  Modified files:  
/ZendEngine2zend_gc.c zend_gc.h 
/ZendEngine2/tests  bug43918.phpt 
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fixed bug #43918 (Segmentation fault in garbage collector)
  
  http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_gc.c?r1=1.3r2=1.4diff_format=u
Index: ZendEngine2/zend_gc.c
diff -u ZendEngine2/zend_gc.c:1.3 ZendEngine2/zend_gc.c:1.4
--- ZendEngine2/zend_gc.c:1.3   Thu Jan 24 11:54:55 2008
+++ ZendEngine2/zend_gc.c   Tue Jan 29 09:59:53 2008
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: zend_gc.c,v 1.3 2008/01/24 11:54:55 dmitry Exp $ */
+/* $Id: zend_gc.c,v 1.4 2008/01/29 09:59:53 dmitry Exp $ */
 
 #include zend.h
 #include zend_API.h
@@ -47,6 +47,7 @@
 static void gc_globals_ctor_ex(zend_gc_globals *gc_globals TSRMLS_DC)
 {
gc_globals-gc_enabled = 0;
+   gc_globals-gc_active = 0;
 
gc_globals-buf = NULL;
 
@@ -156,8 +157,11 @@
zv-refcount__gc++;
gc_collect_cycles(TSRMLS_C);
zv-refcount__gc--;
-   GC_ZVAL_SET_PURPLE(zv);
newRoot = GC_G(unused);
+   if (!newRoot) {
+   return;
+   }
+   GC_ZVAL_SET_PURPLE(zv);
}
 
GC_G(unused) = newRoot-prev;
@@ -183,7 +187,8 @@
 {
struct _store_object *obj;
 
-   if (UNEXPECTED(Z_OBJ_HT_P(zv)-get_properties == NULL)) {
+   if (UNEXPECTED(Z_OBJ_HT_P(zv)-get_properties == NULL ||
+   EG(objects_store).object_buckets == NULL)) {
return;
}
 
@@ -203,9 +208,12 @@
zv-refcount__gc++;
gc_collect_cycles(TSRMLS_C);
zv-refcount__gc--;
+   newRoot = GC_G(unused);
+   if (!newRoot) {
+   return;
+   }
obj = 
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zv)].bucket.obj;
GC_SET_PURPLE(obj-buffered);
-   newRoot = GC_G(unused);
}
 
GC_G(unused) = newRoot-prev;
@@ -240,7 +248,7 @@
 {
GC_ZVAL_SET_BLACK(pz);
 
-   if (Z_TYPE_P(pz) == IS_OBJECT) {
+   if (Z_TYPE_P(pz) == IS_OBJECT  EG(objects_store).object_buckets) {
struct _store_object *obj = 
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;
 
obj-refcount++;
@@ -282,7 +290,7 @@
GC_BENCH_INC(zval_marked_grey);
GC_ZVAL_SET_COLOR(pz, GC_GREY);
 
-   if (Z_TYPE_P(pz) == IS_OBJECT) {
+   if (Z_TYPE_P(pz) == IS_OBJECT  
EG(objects_store).object_buckets) {
struct _store_object *obj = 
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;
 
obj-refcount--;
@@ -309,7 +317,7 @@
gc_root_buffer *current = GC_G(roots).next;
 
while (current != GC_G(roots)) {
-   if (current-handle) {
+   if (current-handle  EG(objects_store).object_buckets) {
struct _store_object *obj = 
EG(objects_store).object_buckets[current-handle].bucket.obj;
 
if (GC_GET_COLOR(obj-buffered) == GC_PURPLE) {
@@ -337,15 +345,17 @@
 
 static void zobj_scan(zval *pz TSRMLS_DC)
 {
-   struct _store_object *obj = 
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;
+   if (EG(objects_store).object_buckets) {
+   struct _store_object *obj = 
EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;
 
-   if (GC_GET_COLOR(obj-buffered) == GC_GREY) {
-   if (obj-refcount  0) {
-   zobj_scan_black(obj, pz TSRMLS_CC);
-   } else {
-   GC_SET_COLOR(obj-buffered, GC_WHITE);
-   if (EXPECTED(Z_OBJ_HANDLER_P(pz, get_properties) != 
NULL)) {
-   zend_hash_apply(Z_OBJPROP_P(pz), (apply_func_t) 
children_scan TSRMLS_CC);
+   if (GC_GET_COLOR(obj-buffered) == GC_GREY) {
+   if (obj-refcount  0) {
+   zobj_scan_black(obj, pz TSRMLS_CC);
+   } else {
+   GC_SET_COLOR(obj-buffered, GC_WHITE);
+   if (EXPECTED(Z_OBJ_HANDLER_P(pz, 
get_properties) != NULL)) {
+   zend_hash_apply(Z_OBJPROP_P(pz), 
(apply_func_t) children_scan TSRMLS_CC);
+   }
}
   

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug37076_1.phpt

2008-01-23 Thread Antony Dovgal
tony2001Wed Jan 23 09:59:42 2008 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug37076_1.phpt 
  Log:
  MFH: fix leak appearing when appending data to unnamed attribute
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.249r2=1.250diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.249 
php-src/ext/simplexml/simplexml.c:1.250
--- php-src/ext/simplexml/simplexml.c:1.249 Tue Jan 22 20:40:30 2008
+++ php-src/ext/simplexml/simplexml.c   Wed Jan 23 09:59:42 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.249 2008/01/22 20:40:30 helly Exp $ */
+/* $Id: simplexml.c,v 1.250 2008/01/23 09:59:42 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -461,7 +461,7 @@
 
 /* {{{ sxe_property_write()
  */
-static void sxe_prop_dim_write(zval *object, zval *member, zval *value, 
zend_bool elements, zend_bool attribs, xmlNodePtr *pnewnode TSRMLS_DC)
+static int sxe_prop_dim_write(zval *object, zval *member, zval *value, 
zend_bool elements, zend_bool attribs, xmlNodePtr *pnewnode TSRMLS_DC)
 {
php_sxe_object *sxe;
xmlNodePtr  node;
@@ -475,6 +475,7 @@
int test = 0;
int new_value = 0;
longcnt = 0;
+   int retval = SUCCESS;
zvaltmp_zv, trim_zv, value_copy;
 
sxe = php_sxe_fetch_object(object TSRMLS_CC);
@@ -489,7 +490,7 @@
 * and this is during runtime.
 */
php_error_docref(NULL TSRMLS_CC, E_ERROR, Cannot 
create unnamed attribute);
-   return;
+   return FAILURE;
}
} else {
if (Z_TYPE_P(member) != IS_STRING) {
@@ -506,7 +507,7 @@
if (member == tmp_zv) {
zval_dtor(tmp_zv);
}
-   return;
+   return FAILURE;
}
}
 
@@ -530,7 +531,7 @@
 * and this is during runtime.
 */
php_error_docref(NULL TSRMLS_CC, E_ERROR, Cannot 
create unnamed attribute);
-   return;
+   return FAILURE;
}
if (attribs  !node  sxe-iter.type == SXE_ITER_ELEMENT) {
node = xmlNewChild(mynode, mynode-ns, sxe-iter.name, 
NULL);
@@ -572,7 +573,7 @@
zval_dtor(tmp_zv);
}
zend_error(E_WARNING, It is not yet possible 
to assign complex types to %s, attribs ? attributes : properties);
-   return;
+   return FAILURE;
}
}
 
@@ -607,7 +608,7 @@
if (!member || Z_TYPE_P(member) == IS_LONG) {
if (node-type == XML_ATTRIBUTE_NODE) {
php_error_docref(NULL TSRMLS_CC, 
E_ERROR, Cannot create duplicate attribute);
-   return;
+   return FAILURE;
}
 
if (sxe-iter.type == SXE_ITER_NONE) {
@@ -615,6 +616,7 @@
++counter;
if (member  Z_LVAL_P(member)  0) {
php_error_docref(NULL 
TSRMLS_CC, E_WARNING, Cannot add element %s number %ld when only 0 such 
elements exist, mynode-name, Z_LVAL_P(member));
+   retval = FAILURE;
}
} else if (member) {
newnode = 
sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node, cnt);
@@ -651,6 +653,7 @@
}
} else if (counter  1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot 
assign to an array of nodes (duplicate subnodes or attr detected));
+   retval = FAILURE;
} else if (elements) {
if (!node) {
if (!member || Z_TYPE_P(member) == IS_LONG) {
@@ -661,12 +664,14 @@
} else if (!member || Z_TYPE_P(member) == IS_LONG) {
if (member  cnt  Z_LVAL_P(member)) {
php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Cannot add element %s number %ld when only %ld such elements 
exist, mynode-name, Z_LVAL_P(member), cnt);
+   retval = 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug37076.phpt

2008-01-22 Thread Marcus Boerger
helly   Tue Jan 22 20:40:30 2008 UTC

  Added files: 
/php-src/ext/simplexml/testsbug37076.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Bugfix #37076 (SimpleXML ignores .=). (felipe, marcus)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.248r2=1.249diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.248 
php-src/ext/simplexml/simplexml.c:1.249
--- php-src/ext/simplexml/simplexml.c:1.248 Mon Dec 31 07:12:14 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jan 22 20:40:30 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.248 2007/12/31 07:12:14 sebastian Exp $ */
+/* $Id: simplexml.c,v 1.249 2008/01/22 20:40:30 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -719,11 +719,13 @@
 
name = Z_STRVAL_P(member);
node = sxe_get_element_by_name(sxe, node, name, type TSRMLS_CC);
-   if (!node) {
-   sxe_prop_dim_write(object, member, NULL, 1, 0, node TSRMLS_CC);
-   type = SXE_ITER_NONE;
-   name = NULL;
+   if (node) {
+   return NULL;
}
+   sxe_prop_dim_write(object, member, NULL, 1, 0, node TSRMLS_CC);
+   type = SXE_ITER_NONE;
+   name = NULL;
+
MAKE_STD_ZVAL(return_value);
_node_as_zval(sxe, node, return_value, type, name, sxe-iter.nsprefix, 
sxe-iter.isprefix TSRMLS_CC);
 
@@ -2531,7 +2533,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.248 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.249 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug37076.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug37076.phpt
+++ php-src/ext/simplexml/tests/bug37076.phpt
--TEST--
Bug #37076 (SimpleXML ignores .=)
--FILE--
?php
$xml = simplexml_load_string(rootfoo //root);
$xml-foo = foo;
$xml-foo .= bar;
print $xml-asXML();
?
===DONE===
--EXPECT--
?xml version=1.0?
rootfoofoobar/foo/root
===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 simplexml.c

2007-11-30 Thread Antony Dovgal
tony2001Fri Nov 30 13:15:38 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix folding, move protos to the top of the sources
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.246r2=1.247diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.246 
php-src/ext/simplexml/simplexml.c:1.247
--- php-src/ext/simplexml/simplexml.c:1.246 Mon Nov 12 18:58:01 2007
+++ php-src/ext/simplexml/simplexml.c   Fri Nov 30 13:15:38 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.246 2007/11/12 18:58:01 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.247 2007/11/30 13:15:38 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -43,10 +43,11 @@
 
 zend_class_entry *sxe_class_entry = NULL;
 
-ZEND_API zend_class_entry *sxe_get_element_class_entry(TSRMLS_D)
+ZEND_API zend_class_entry *sxe_get_element_class_entry(TSRMLS_D) /* {{{ */
 {
return sxe_class_entry;
 }
+/* }}} */
 
 #define SXE_ME(func, arg_info, flags) PHP_ME(simplexml_element, func, 
arg_info, flags)
 #define SXE_MALIAS(func, alias, arg_info, flags) PHP_MALIAS(simplexml_element, 
func, alias, arg_info, flags)
@@ -59,6 +60,13 @@
 static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, 
int use_data TSRMLS_DC);
 static zval *sxe_get_value(zval *z TSRMLS_DC);
 
+static void php_sxe_iterator_dtor(zend_object_iterator *iter TSRMLS_DC);
+static int php_sxe_iterator_valid(zend_object_iterator *iter TSRMLS_DC);
+static void php_sxe_iterator_current_data(zend_object_iterator *iter, zval 
***data TSRMLS_DC);
+static int php_sxe_iterator_current_key(zend_object_iterator *iter, zstr 
*str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
+static void php_sxe_iterator_move_forward(zend_object_iterator *iter 
TSRMLS_DC);
+static void php_sxe_iterator_rewind(zend_object_iterator *iter TSRMLS_DC);
+
 /* {{{ _node_as_zval()
  */
 static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, 
SXE_ITER itertype, char *name, xmlChar *nsprefix, int isprefix TSRMLS_DC)
@@ -104,7 +112,8 @@
} \
 }
 
-static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node 
TSRMLS_DC) {
+static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node 
TSRMLS_DC) /* {{{ */
+{
php_sxe_object *intern;
xmlNodePtr retnode = NULL;
 
@@ -119,6 +128,7 @@
return node;
}
 }
+/* }}} */
 
 static inline int match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar 
*name, int prefix) /* {{{ */
 {
@@ -1014,7 +1024,7 @@
 }
 /* }}} */
 
-static void sxe_properties_add(HashTable *rv, char *name, int namelen, zval 
*value TSRMLS_DC)
+static void sxe_properties_add(HashTable *rv, char *name, int namelen, zval 
*value TSRMLS_DC) /* {{{ */
 {
zval  **data_ptr;
zval  *newptr;
@@ -1037,6 +1047,7 @@
zend_hash_quick_update(rv, name, namelen, h, value, 
sizeof(zval *), NULL);
}
 }
+/* }}} */
 
 static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* 
{{{ */
 {
@@ -1399,7 +1410,7 @@
 
 #define SXE_NS_PREFIX(ns) (ns-prefix ? (char*)ns-prefix : )
 
-static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns 
TSRMLS_DC)
+static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns 
TSRMLS_DC) /* {{{ */
 {
uint prefix_len;
char *prefix = SXE_NS_PREFIX(ns);
@@ -1422,6 +1433,7 @@
}
}
 }
+/* }}} */
 
 static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, zend_bool 
recursive, zval *return_value TSRMLS_DC) /* {{{ */
 {
@@ -1857,7 +1869,7 @@
 }
 /* }}} */
 
-static zval *sxe_get_value(zval *z TSRMLS_DC)
+static zval *sxe_get_value(zval *z TSRMLS_DC) /* {{{ */
 {
zval *retval;
 
@@ -1871,9 +1883,9 @@
Z_SET_REFCOUNT_P(retval, 0);
return retval;
 }
+/* }}} */
 
-
-static zend_object_handlers sxe_object_handlers = {
+static zend_object_handlers sxe_object_handlers = { /* {{{ */
ZEND_OBJECTS_STORE_HANDLERS,
sxe_property_read,
sxe_property_write,
@@ -1897,6 +1909,7 @@
sxe_count_elements,
sxe_get_debug_info
 };
+/* }}} */
 
 /* {{{ sxe_object_clone()
  */
@@ -2128,7 +2141,6 @@
 }
 /* }}} */
 
-
 /* {{{ proto SimpleXMLElement::__construct(string data [, int options [, bool 
data_is_url [, string ns [, bool is_prefix) U
SimpleXMLElement constructor */
 SXE_METHOD(__construct)
@@ -2180,15 +2192,7 @@
 }
 /* }}} */
 
-
-static void php_sxe_iterator_dtor(zend_object_iterator *iter TSRMLS_DC);
-static int php_sxe_iterator_valid(zend_object_iterator *iter TSRMLS_DC);
-static void php_sxe_iterator_current_data(zend_object_iterator *iter, zval 
***data TSRMLS_DC);
-static int php_sxe_iterator_current_key(zend_object_iterator *iter, zstr 
*str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
-static 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug43221.phpt

2007-11-12 Thread Rob Richards
rrichards   Mon Nov 12 18:58:01 2007 UTC

  Added files: 
/php-src/ext/simplexml/testsbug43221.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #43221 (SimpleXML adding default namespace in addAttribute)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.245r2=1.246diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.245 
php-src/ext/simplexml/simplexml.c:1.246
--- php-src/ext/simplexml/simplexml.c:1.245 Sun Oct  7 05:15:04 2007
+++ php-src/ext/simplexml/simplexml.c   Mon Nov 12 18:58:01 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.245 2007/10/07 05:15:04 davidw Exp $ */
+/* $Id: simplexml.c,v 1.246 2007/11/12 18:58:01 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1697,6 +1697,13 @@
 
localname = xmlSplitQName2((xmlChar *)qname, prefix);
if (localname == NULL) {
+   if (nsuri_len  0) {
+   if (prefix != NULL) {
+   xmlFree(prefix);
+   }
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Attribute 
requires prefix for namespace);
+   return;
+   }
localname = xmlStrdup((xmlChar *)qname);
}
 
@@ -2503,7 +2510,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.245 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.246 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug43221.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug43221.phpt
+++ php-src/ext/simplexml/tests/bug43221.phpt
--TEST--
Bug #43221 (SimpleXML adding default namespace in addAttribute)
--FILE--
?php
$xml = simplexml_load_string('?xml version=1.0 encoding=utf-8?root /');
$n = $xml-addChild(node, value);
$n-addAttribute(a, b);
$n-addAttribute(c, d, http://bar.com;);
$n-addAttribute(foo:e, f, http://bar.com;);
print_r($xml-asXml());
?
--EXPECTF--
Warning: SimpleXMLElement::addAttribute(): Attribute requires prefix for 
namespace in %sbug43221.php on line %d
?xml version=1.0 encoding=utf-8?
rootnode xmlns:foo=http://bar.com; a=b foo:e=fvalue/node/root

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2007-07-31 Thread Rob Richards
rrichards   Tue Jul 31 15:07:15 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix possible crash
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.241r2=1.242diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.241 
php-src/ext/simplexml/simplexml.c:1.242
--- php-src/ext/simplexml/simplexml.c:1.241 Tue Jul 10 12:26:37 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jul 31 15:07:15 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.241 2007/07/10 12:26:37 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.242 2007/07/31 15:07:15 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1637,7 +1637,9 @@
newnode-ns = NULL;
nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, prefix);
} else {
-   nsptr = xmlSearchNsByHref(node-doc, node, (xmlChar 
*)nsuri);
+   if (node) {
+   nsptr = xmlSearchNsByHref(node-doc, node, 
(xmlChar *)nsuri);
+   }
if (nsptr == NULL) {
nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, 
prefix);
}
@@ -2498,7 +2500,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.241 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.242 $);
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 simplexml.c

2007-07-31 Thread Rob Richards
rrichards   Tue Jul 31 15:40:00 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix bug #41833 (addChild() on a non-existent node, no node created, getName() 
segfaults)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.242r2=1.243diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.242 
php-src/ext/simplexml/simplexml.c:1.243
--- php-src/ext/simplexml/simplexml.c:1.242 Tue Jul 31 15:07:15 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jul 31 15:39:59 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.242 2007/07/31 15:07:15 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.243 2007/07/31 15:39:59 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1625,6 +1625,11 @@
 
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
+   if (node == NULL) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot add child. 
Parent is not a permanent member of the XML tree);
+   return; 
+   }
+
localname = xmlSplitQName2((xmlChar *)qname, prefix);
if (localname == NULL) {
localname = xmlStrdup((xmlChar *)qname);
@@ -1637,9 +1642,7 @@
newnode-ns = NULL;
nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, prefix);
} else {
-   if (node) {
-   nsptr = xmlSearchNsByHref(node-doc, node, 
(xmlChar *)nsuri);
-   }
+   nsptr = xmlSearchNsByHref(node-doc, node, (xmlChar 
*)nsuri);
if (nsptr == NULL) {
nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, 
prefix);
}
@@ -2500,7 +2503,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.242 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.243 $);
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 simplexml.c /ext/simplexml/tests bug41947.phpt

2007-07-10 Thread Rob Richards
rrichards   Tue Jul 10 12:26:38 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug41947.phpt 
  Log:
  MFB: fix bug #41947 (SimpleXML incorrectly registers empty strings as 
namespaces
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.240r2=1.241diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.240 
php-src/ext/simplexml/simplexml.c:1.241
--- php-src/ext/simplexml/simplexml.c:1.240 Wed Jul  4 05:05:32 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jul 10 12:26:37 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.240 2007/07/04 05:05:32 pollita Exp $ */
+/* $Id: simplexml.c,v 1.241 2007/07/10 12:26:37 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1633,11 +1633,16 @@
newnode = xmlNewChild(node, NULL, localname, (xmlChar *)value);
 
if (nsuri != NULL) {
-   nsptr = xmlSearchNsByHref(node-doc, node, (xmlChar *)nsuri);
-   if (nsptr == NULL) {
+   if (nsuri_len == 0) {
+   newnode-ns = NULL;
nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, prefix);
+   } else {
+   nsptr = xmlSearchNsByHref(node-doc, node, (xmlChar 
*)nsuri);
+   if (nsptr == NULL) {
+   nsptr = xmlNewNs(newnode, (xmlChar *)nsuri, 
prefix);
+   }
+   newnode-ns = nsptr;
}
-   newnode-ns = nsptr;
}
 
_node_as_zval(sxe, newnode, return_value, SXE_ITER_NONE, (char 
*)localname, prefix, 0 TSRMLS_CC);
@@ -2493,7 +2498,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.240 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.241 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug41947.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug41947.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug41947.phpt:1.2
--- /dev/null   Tue Jul 10 12:26:38 2007
+++ php-src/ext/simplexml/tests/bug41947.phpt   Tue Jul 10 12:26:37 2007
@@ -0,0 +1,14 @@
+--TEST--
+Bug #41947 (addChild incorrectly registers empty strings as namespaces)
+--FILE--
+?php
+$xml = simplexml_load_string('?xml version=1.0 encoding=utf-8?root 
xmlns:myns=http://myns; /');
+$grandchild = $xml-addChild('child', null, 
'http://myns')-addChild('grandchild', 'hello', '');
+
+$gchild = $xml-xpath(//grandchild);
+if (count($gchild)  0) {
+echo $gchild[0];
+}
+?
+--EXPECT--
+hello

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug41861.phpt

2007-07-03 Thread Rob Richards
rrichards   Tue Jul  3 15:02:40 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug41861.phpt 
  Log:
  MFB: fix bug #41861 (getNamespaces() returns namespaces of node's siblings)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.238r2=1.239diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.238 
php-src/ext/simplexml/simplexml.c:1.239
--- php-src/ext/simplexml/simplexml.c:1.238 Mon Jul  2 11:53:08 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jul  3 15:02:40 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.238 2007/07/02 11:53:08 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.239 2007/07/03 15:02:40 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1458,15 +1458,12 @@
GET_NODE(sxe, node);
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
-   while (node) {
-   SKIP_TEXT(node)
+   if (node) {
if (node-type == XML_ELEMENT_NODE) {
sxe_add_namespaces(sxe, node, recursive, return_value 
TSRMLS_CC);
} else if (node-type == XML_ATTRIBUTE_NODE  node-ns) {
sxe_add_namespace_name(return_value, node-ns 
TSRMLS_CC);
}
-next_iter:
-   node = node-next;
}
 }
 /* }}} */
@@ -2486,7 +2483,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.238 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.239 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug41861.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug41861.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug41861.phpt:1.2
--- /dev/null   Tue Jul  3 15:02:40 2007
+++ php-src/ext/simplexml/tests/bug41861.phpt   Tue Jul  3 15:02:40 2007
@@ -0,0 +1,38 @@
+--TEST--
+Bug #41861 (getNamespaces() returns the namespaces of a node's siblings)
+--FILE--
+?php
+
+$xml = simplexml_load_string('root
+   first_node_no_ns /
+   ns1:node1 xmlns:ns1=#ns1 /
+   ns2:node2 xmlns:ns2=#ns2 /
+   ns3:node3 xmlns:ns3=#ns3 /
+   last_node_no_ns /
+/root');
+
+$name = $xml-getName();
+$namespaces = $xml-getNamespaces(True);
+echo root(recursive): '$name' -- namespaces: , implode(', ', $namespaces), 
\n;
+$namespaces = $xml-getNamespaces(False);
+echo root(non-recursive): '$name' -- namespaces: , implode(', ', 
$namespaces), \n;
+
+foreach (array(null, '#ns1', '#ns2', '#ns3') as $ns)
+{
+   foreach ($xml-children($ns) as $child)
+   {
+   $name = $child-getName();
+   $namespaces = $child-getNamespaces(false);
+
+   echo children($ns): '$name' -- namespaces: , implode(', ', 
$namespaces), \n;
+   }
+}
+?
+--EXPECT--
+root(recursive): 'root' -- namespaces: #ns1, #ns2, #ns3
+root(non-recursive): 'root' -- namespaces: 
+children(): 'first_node_no_ns' -- namespaces: 
+children(): 'last_node_no_ns' -- namespaces: 
+children(#ns1): 'node1' -- namespaces: #ns1
+children(#ns2): 'node2' -- namespaces: #ns2
+children(#ns3): 'node3' -- namespaces: #ns3

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2007-07-03 Thread Sara Golemon
pollita Wed Jul  4 05:05:32 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fix behavior of empty($sxe-element) and empty($sxe['prop'])
  when used on empty elements properties (apply PHP emptiness rules)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.239r2=1.240diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.239 
php-src/ext/simplexml/simplexml.c:1.240
--- php-src/ext/simplexml/simplexml.c:1.239 Tue Jul  3 15:02:40 2007
+++ php-src/ext/simplexml/simplexml.c   Wed Jul  4 05:05:32 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.239 2007/07/03 15:02:40 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.240 2007/07/04 05:05:32 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -797,6 +797,11 @@
attr = attr-next;
}
}
+   if (exists  check_empty == 1 
+   (!attr-children || !attr-children-content || 
!attr-children-content[0] || !xmlStrcmp(attr-children-content, 0)) ) {
+   /* Attribute with no content in it's text node 
*/
+   exists = 0;
+   }
}
 
if (elements) {
@@ -819,6 +824,11 @@
}
if (node) {
exists = 1;
+if (check_empty == 1  
+   (!node-children || 
(node-children-type == XML_TEXT_NODE  !node-children-next 
+   (!node-children-content || 
!node-children-content[0] || !xmlStrcmp(node-children-content, 0 ) {
+   exists = 0;
+   }
}
}
}
@@ -2483,7 +2493,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.239 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.240 $);
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 simplexml.c /ext/simplexml/tests bug41867.phpt

2007-07-02 Thread Rob Richards
rrichards   Mon Jul  2 11:36:28 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug41867.phpt 
  Log:
  MFB: fix bug #41867 (getName is broken)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.236r2=1.237diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.236 
php-src/ext/simplexml/simplexml.c:1.237
--- php-src/ext/simplexml/simplexml.c:1.236 Fri Jun 29 13:58:34 2007
+++ php-src/ext/simplexml/simplexml.c   Mon Jul  2 11:36:28 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.236 2007/06/29 13:58:34 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.237 2007/07/02 11:36:28 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1550,9 +1550,13 @@
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
 
GET_NODE(sxe, node);
-   
-   namelen = xmlStrlen(node-name);
-   RETVAL_XML_STRING_LEN((char *) node-name, namelen, ZSTR_DUPLICATE);
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+   if (node) {
+   namelen = xmlStrlen(node-name);
+   RETVAL_XML_STRING_LEN((char *) node-name, namelen, 
ZSTR_DUPLICATE);
+   } else {
+   RETURN_EMPTY_TEXT();
+   }
 }
 /* }}} */
 
@@ -2482,7 +2486,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.236 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.237 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug41867.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug41867.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug41867.phpt:1.2
--- /dev/null   Mon Jul  2 11:36:28 2007
+++ php-src/ext/simplexml/tests/bug41867.phpt   Mon Jul  2 11:36:28 2007
@@ -0,0 +1,14 @@
+--TEST--
+Bug #41867 (getName is broken)
+--FILE--
+?php
+
+$a = simplexml_load_string(abc//b/a);
+echo $a-getName().\n;
+echo $a-b-getName().\n;
+echo $a-b-c-getName();
+?
+--EXPECT--
+a
+b
+c

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2007-07-02 Thread Dmitry Stogov
dmitry  Mon Jul  2 11:53:08 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Allow unicode XML
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.237r2=1.238diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.237 
php-src/ext/simplexml/simplexml.c:1.238
--- php-src/ext/simplexml/simplexml.c:1.237 Mon Jul  2 11:36:28 2007
+++ php-src/ext/simplexml/simplexml.c   Mon Jul  2 11:53:08 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.237 2007/07/02 11:36:28 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.238 2007/07/02 11:53:08 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -2110,7 +2110,8 @@
 SXE_METHOD(__construct)
 {
php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
-   char   *data, *ns = NULL;
+   zstrdata;
+   char   *ns = NULL;
int data_len, ns_len = 0;
xmlDocPtr   docp;
longoptions = 0;
@@ -2127,20 +2128,19 @@
 
if (data_type == IS_UNICODE) {
if (is_url) {
-   if (php_stream_path_encode(NULL, data, data_len, 
(UChar*)data, data_len, REPORT_ERRORS, NULL) == FAILURE) {
+   if (php_stream_path_encode(NULL, data.s, data_len, 
data.u, data_len, REPORT_ERRORS, NULL) == FAILURE) {

zend_throw_exception(zend_exception_get_default(TSRMLS_C), String could not be 
parsed as XML, 0 TSRMLS_CC);
return;
}
} else {
-   
zend_throw_exception(zend_exception_get_default(TSRMLS_C), SimpleXMLElement 
can only parse a binary string, 0 TSRMLS_CC);
-   return;
+   data.s = php_libxml_unicode_to_string(data.u, data_len, 
data_len TSRMLS_CC);
}
}
 
-   docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, 
data_len, NULL, NULL, options);
+   docp = is_url ? xmlReadFile(data.s, NULL, options) : 
xmlReadMemory(data.s, data_len, NULL, NULL, options);
 
-   if (is_url  data_type == IS_UNICODE) {
-   efree(data);
+   if (data_type == IS_UNICODE) {
+   efree(data.s);
}
 
if (!docp) {
@@ -2486,7 +2486,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.237 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.238 $);
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 simplexml.c

2007-06-24 Thread Nuno Lopes
nlopess Sun Jun 24 11:43:34 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  MFB:fix memleak in sxe_prop_dim_read()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.234r2=1.235diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.234 
php-src/ext/simplexml/simplexml.c:1.235
--- php-src/ext/simplexml/simplexml.c:1.234 Wed Jun 13 13:38:59 2007
+++ php-src/ext/simplexml/simplexml.c   Sun Jun 24 11:43:34 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.234 2007/06/13 13:38:59 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.235 2007/06/24 11:43:34 nlopess Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -271,9 +271,6 @@
name = Z_STRVAL_P(member);
}
 
-   MAKE_STD_ZVAL(return_value);
-   ZVAL_NULL(return_value);
-
GET_NODE(sxe, node);
 
if (sxe-iter.type == SXE_ITER_ATTRLIST) {
@@ -294,6 +291,9 @@
}
}
 
+   MAKE_STD_ZVAL(return_value);
+   ZVAL_NULL(return_value);
+
if (node) {
if (attribs) {
if (Z_TYPE_P(member) != IS_LONG || sxe-iter.type == 
SXE_ITER_ATTRLIST) {
@@ -2474,7 +2474,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.234 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.235 $);
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 simplexml.c /ext/simplexml/tests 027.phpt bug35785.phpt bug41582.phpt

2007-06-13 Thread Dmitry Stogov
dmitry  Wed Jun 13 13:39:00 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests027.phpt bug35785.phpt bug41582.phpt 
  Log:
  Fixed wrong fic for bug #41582
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.233r2=1.234diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.233 
php-src/ext/simplexml/simplexml.c:1.234
--- php-src/ext/simplexml/simplexml.c:1.233 Tue Jun  5 10:02:02 2007
+++ php-src/ext/simplexml/simplexml.c   Wed Jun 13 13:38:59 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.233 2007/06/05 10:02:02 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.234 2007/06/13 13:38:59 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -249,18 +249,16 @@
int nodendx = 0;
int test = 0;
 
-   if (!member) {
-   return_value = EG(uninitialized_zval);
-   return_value-is_ref = 1;
-   return return_value;
-   }
-
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
-   if (Z_TYPE_P(member) == IS_LONG) {
+   if (!member || Z_TYPE_P(member) == IS_LONG) {
if (sxe-iter.type != SXE_ITER_ATTRLIST) {
attribs = 0;
elements = 1;
+   } else if (!member) {
+   /* This happens when the user did: $sxe[]-foo = $value 
*/
+   php_error_docref(NULL TSRMLS_CC, E_ERROR, Cannot 
create unnamed attribute);
+   return NULL;
}
name = NULL;
} else {
@@ -288,6 +286,12 @@
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
attr = node ? node-properties : NULL;
test = 0;
+   if (!member  node  node-parent 
+   node-parent-type == XML_DOCUMENT_NODE) {
+   /* This happens when the user did: $sxe[]-foo = $value 
*/
+   php_error_docref(NULL TSRMLS_CC, E_ERROR, Cannot 
create unnamed attribute);
+   return NULL;
+   }
}
 
if (node) {
@@ -320,13 +324,30 @@
if (!sxe-node) {

php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, node, NULL 
TSRMLS_CC);
}
-   if (Z_TYPE_P(member) == IS_LONG) {
+   if (!member || Z_TYPE_P(member) == IS_LONG) {
+   long cnt = 0;
+   xmlNodePtr mynode = node;
+
if (sxe-iter.type == SXE_ITER_CHILD) {
node = php_sxe_get_first_node(sxe, node 
TSRMLS_CC);
}
-   node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node, NULL);
+   if (sxe-iter.type == SXE_ITER_NONE) {
+   if (member  Z_LVAL_P(member)  0) {
+   php_error_docref(NULL 
TSRMLS_CC, E_WARNING, Cannot add element %s number %ld when only 0 such 
elements exist, mynode-name, Z_LVAL_P(member));
+   }
+   } else if (member) {
+   node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node, cnt);
+   } else {
+   node = NULL;
+   }
if (node) {
_node_as_zval(sxe, node, return_value, 
SXE_ITER_NONE, NULL, sxe-iter.nsprefix, sxe-iter.isprefix TSRMLS_CC);
+   } else if (type == BP_VAR_W || type == 
BP_VAR_RW) {
+   if (member  cnt  Z_LVAL_P(member)) {
+   php_error_docref(NULL 
TSRMLS_CC, E_WARNING, Cannot add element %s number %ld when only %ld such 
elements exist, mynode-name, Z_LVAL_P(member), cnt);
+   }
+   node = xmlNewTextChild(mynode-parent, 
mynode-ns, mynode-name, NULL);
+   _node_as_zval(sxe, node, return_value, 
SXE_ITER_NONE, NULL, sxe-iter.nsprefix, sxe-iter.isprefix TSRMLS_CC);
}
} else {
 #if SXE_ELEMENT_BY_NAME
@@ -432,7 +453,6 @@
 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;
xmlNodePtr  node;
xmlNodePtr  newnode = 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug41582.phpt

2007-06-05 Thread Antony Dovgal
tony2001Tue Jun  5 10:02:02 2007 UTC

  Added files: 
/php-src/ext/simplexml/testsbug41582.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix #41582 (SimpleXML crashes when accessing newly created element)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.232r2=1.233diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.232 
php-src/ext/simplexml/simplexml.c:1.233
--- php-src/ext/simplexml/simplexml.c:1.232 Mon May 28 23:14:57 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jun  5 10:02:02 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.232 2007/05/28 23:14:57 iliaa Exp $ */
+/* $Id: simplexml.c,v 1.233 2007/06/05 10:02:02 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -238,7 +238,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, int type TSRMLS_DC)
 {
zval   *return_value;
php_sxe_object *sxe;
@@ -249,6 +249,12 @@
int nodendx = 0;
int test = 0;
 
+   if (!member) {
+   return_value = EG(uninitialized_zval);
+   return_value-is_ref = 1;
+   return return_value;
+   }
+
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
if (Z_TYPE_P(member) == IS_LONG) {
@@ -357,7 +363,7 @@
  */
 static zval * sxe_property_read(zval *object, zval *member, int type TSRMLS_DC)
 {
-   return sxe_prop_dim_read(object, member, 1, 0, type == BP_VAR_IS 
TSRMLS_CC);
+   return sxe_prop_dim_read(object, member, 1, 0, type TSRMLS_CC);
 }
 /* }}} */
 
@@ -365,7 +371,7 @@
  */
 static zval * sxe_dimension_read(zval *object, zval *offset, int type 
TSRMLS_DC)
 {
-   return sxe_prop_dim_read(object, offset, 0, 1, 0 TSRMLS_CC);
+   return sxe_prop_dim_read(object, offset, 0, 1, type TSRMLS_CC);
 }
 /* }}} */
 
@@ -2425,7 +2431,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.232 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.233 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug41582.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug41582.phpt
+++ php-src/ext/simplexml/tests/bug41582.phpt
--TEST--
Bug #41582 (SimpleXML crashes when accessing newly created element)
--FILE--
?php

$xml = new SimpleXMLElement(b'?xml version=1.0 
standalone=yes?collection/collection');

$xml-movie[]-characters-character[0]-name = b'Miss Coder';

var_dump($xml-asXml());

echo Done\n;
?
--EXPECTF-- 
Fatal error: Cannot use object of type stdClass as array in %s 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 /ext/simplexml simplexml.c /ext/simplexml/tests bug37386.phpt

2007-03-26 Thread Rob Richards
rrichards   Mon Mar 26 20:16:16 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug37386.phpt 
  Log:
  MFB: fix bug #37386 (autocreating element doesn't assign value to first node)
  all single SimpleXMLElements are addressable using offset 0
  use correct node for xpath context node
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.230r2=1.231diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.230 
php-src/ext/simplexml/simplexml.c:1.231
--- php-src/ext/simplexml/simplexml.c:1.230 Tue Feb 20 14:04:59 2007
+++ php-src/ext/simplexml/simplexml.c   Mon Mar 26 20:16:15 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.230 2007/02/20 14:04:59 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.231 2007/03/26 20:16:15 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -138,7 +138,14 @@
long nodendx = 0;

if (sxe-iter.type == SXE_ITER_NONE) {
-   return NULL;
+   if (offset == 0) {
+   if (cnt) {
+   *cnt = 0;
+   }
+   return node;
+   } else {
+   return NULL;
+   }
}
while (node  nodendx = offset) {
SKIP_TEXT(node)
@@ -430,7 +437,7 @@
int nodendx = 0;
int test = 0;
int new_value = 0;
-   longcnt;
+   longcnt = 0;
zvaltmp_zv, trim_zv, value_copy;
 
if (!member) {
@@ -1158,9 +1165,11 @@
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
xmlDocGetRootElement((xmlDocPtr) sxe-document-ptr), NULL TSRMLS_CC);
}
 
-   sxe-xpath-node = sxe-node-node;
+   nodeptr = php_sxe_get_first_node(sxe, sxe-node-node TSRMLS_CC);
+
+   sxe-xpath-node = nodeptr;
 
-   ns = xmlGetNsList((xmlDocPtr) sxe-document-ptr, (xmlNodePtr) 
sxe-node-node);
+   ns = xmlGetNsList((xmlDocPtr) sxe-document-ptr, nodeptr);
if (ns != NULL) {
while (ns[nsnbr] != NULL) {
nsnbr++;
@@ -2416,7 +2425,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.230 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.231 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug37386.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug37386.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug37386.phpt:1.2
--- /dev/null   Mon Mar 26 20:16:16 2007
+++ php-src/ext/simplexml/tests/bug37386.phpt   Mon Mar 26 20:16:16 2007
@@ -0,0 +1,25 @@
+--TEST--
+Bug #39760 (autocreating element doesn't assign value to first node)
+--SKIPIF--
+?php if (!extension_loaded(simplexml)) print skip simplexml extension is 
not loaded; ?
+--FILE--
+?php
+
+$sx1 = new SimpleXMLElement((binary)root /);
+
+$sx1-node[0] = 'node1';
+$sx1-node[1] = 'node2';
+
+print $sx1-asXML().\n;
+$node = $sx1-node[0];
+$node[0] = 'New Value';
+
+print $sx1-asXML();
+
+?
+--EXPECTF--
+?xml version=1.0?
+rootnodenode1/nodenodenode2/node/root
+
+?xml version=1.0?
+rootnodeNew Value/nodenodenode2/node/root

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2007-02-20 Thread Antony Dovgal
tony2001Tue Feb 20 13:21:54 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix #38406 (crash when assigning objects to SimpleXML attributes)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.228r2=1.229diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.228 
php-src/ext/simplexml/simplexml.c:1.229
--- php-src/ext/simplexml/simplexml.c:1.228 Mon Feb 12 21:13:01 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Feb 20 13:21:54 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.228 2007/02/12 21:13:01 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.229 2007/02/20 13:21:54 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -56,6 +56,7 @@
 static zend_object_value php_sxe_register_object(php_sxe_object * TSRMLS_DC);
 static xmlNodePtr php_sxe_reset_iterator(php_sxe_object *sxe, int use_data 
TSRMLS_DC);
 static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, 
int use_data TSRMLS_DC);
+static zval *sxe_get_value(zval *z TSRMLS_DC);
 
 /* {{{ _node_as_zval()
  */
@@ -428,6 +429,7 @@
int is_attr = 0;
int nodendx = 0;
int test = 0;
+   int new_value = 0;
longcnt;
zvaltmp_zv, trim_zv, value_copy;
 
@@ -506,8 +508,17 @@
break;
case IS_STRING:
break;
+   case IS_OBJECT:
+   if (Z_OBJCE_P(value) == sxe_class_entry) {
+   value = sxe_get_value(value TSRMLS_CC);
+   INIT_PZVAL(value);
+   new_value = 1;
+   break;
+   }
+   /* break is missing intentionally */
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, It 
is not yet possible to assign complex types to %s, attribs ? attributes : 
properties);
+   return;
}
}
 
@@ -596,6 +607,9 @@
if (value  value == value_copy) {
zval_dtor(value);
}
+   if (new_value) {
+   zval_ptr_dtor(value);
+   }
 }
 /* }}} */
 
@@ -2396,7 +2410,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.228 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.229 $);
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 simplexml.c

2007-02-20 Thread Antony Dovgal
tony2001Tue Feb 20 14:04:59 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix leak, convert unicode values to string before assigning
  change error message to use zend_error() since there is no active function
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.229r2=1.230diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.229 
php-src/ext/simplexml/simplexml.c:1.230
--- php-src/ext/simplexml/simplexml.c:1.229 Tue Feb 20 13:21:54 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Feb 20 14:04:59 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.229 2007/02/20 13:21:54 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.230 2007/02/20 14:04:59 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -513,11 +513,17 @@
value = sxe_get_value(value TSRMLS_CC);
INIT_PZVAL(value);
new_value = 1;
+   if (UG(unicode)) {
+   
convert_to_string_with_converter(value, UG(utf8_conv));
+   }
break;
}
/* break is missing intentionally */
default:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, It 
is not yet possible to assign complex types to %s, attribs ? attributes : 
properties);
+   if (member == tmp_zv) {
+   zval_dtor(tmp_zv);
+   }
+   zend_error(E_WARNING, It is not yet possible 
to assign complex types to %s, attribs ? attributes : properties);
return;
}
}
@@ -2410,7 +2416,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.229 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.230 $);
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 simplexml.c /ext/simplexml/tests bug40451.phpt

2007-02-12 Thread Antony Dovgal
tony2001Mon Feb 12 21:13:01 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug40451.phpt 
  Log:
  MFB: #40451 (addAttribute() may crash when used with non-existent child node)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.227r2=1.228diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.227 
php-src/ext/simplexml/simplexml.c:1.228
--- php-src/ext/simplexml/simplexml.c:1.227 Thu Jan 18 23:23:50 2007
+++ php-src/ext/simplexml/simplexml.c   Mon Feb 12 21:13:01 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.227 2007/01/18 23:23:50 helly Exp $ */
+/* $Id: simplexml.c,v 1.228 2007/02/12 21:13:01 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1586,7 +1586,7 @@
 
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
-   if (node-type != XML_ELEMENT_NODE) {
+   if (node  node-type != XML_ELEMENT_NODE) {
node = node-parent;
}
 
@@ -2396,7 +2396,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.227 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.228 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug40451.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug40451.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug40451.phpt:1.2
--- /dev/null   Mon Feb 12 21:13:01 2007
+++ php-src/ext/simplexml/tests/bug40451.phpt   Mon Feb 12 21:13:01 2007
@@ -0,0 +1,22 @@
+--TEST--
+Bug #40451 (addAttribute() may crash when used with non-existent child node)
+--FILE--
+?php
+
+$string = XML
+?xml version=1.0?
+   Host enable=true
+Namehost.server.com/Name
+/Host
+XML;
+
+$xml = simplexml_load_string((binary)$string);
+
+$add = $xml-addChild('Host');
+$add-Host-addAttribute('enable', 'true');
+
+echo Done\n;
+?
+--EXPECTF--
+Warning: SimpleXMLElement::addAttribute(): Unable to locate parent Element in 
%s on line %d
+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 simplexml.c

2007-01-18 Thread Marcus Boerger
helly   Thu Jan 18 23:23:50 2007 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Implement debug helper
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.226r2=1.227diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.226 
php-src/ext/simplexml/simplexml.c:1.227
--- php-src/ext/simplexml/simplexml.c:1.226 Mon Jan  1 09:29:29 2007
+++ php-src/ext/simplexml/simplexml.c   Thu Jan 18 23:23:50 2007
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.226 2007/01/01 09:29:29 sebastian Exp $ */
+/* $Id: simplexml.c,v 1.227 2007/01/18 23:23:50 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -615,6 +615,7 @@
 }
 /* }}} */
 
+#if HELLY_0
 static zval** sxe_property_get_adr(zval *object, zval *member TSRMLS_DC) /* 
{{{ */
 {
php_sxe_object *sxe;
@@ -639,12 +640,16 @@
_node_as_zval(sxe, node, return_value, type, name, sxe-iter.nsprefix, 
sxe-iter.isprefix TSRMLS_CC);
 
sxe = php_sxe_fetch_object(return_value TSRMLS_CC);
+   if (sxe-tmp) {
+   zval_ptr_dtor(sxe-tmp);
+   }
sxe-tmp = return_value;
return_value-is_ref  = 1;
 
return sxe-tmp;
 }
 /* }}} */
+#endif
 
 /* {{{ sxe_prop_dim_exists()
  */
@@ -946,9 +951,7 @@
}
 }
 
-/* {{{ sxe_properties_get()
- */
-static HashTable * sxe_properties_get(zval *object TSRMLS_DC)
+static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* 
{{{ */
 {
zval*value;
zval*zattr;
@@ -962,7 +965,10 @@
 
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
-   if (sxe-properties) {
+   if (is_debug) {
+   ALLOC_HASHTABLE(rv);
+   zend_u_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0, UG(unicode));
+   } else if (sxe-properties) {
zend_hash_clean(sxe-properties);
rv = sxe-properties;
} else {
@@ -975,7 +981,7 @@
if (!node) {
return rv;
}
-   if (1||sxe-iter.type != SXE_ITER_CHILD) {
+   if (is_debug) {
if (sxe-iter.type == SXE_ITER_ELEMENT) {
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
}
@@ -1066,6 +1072,19 @@
 }
 /* }}} */
 
+static HashTable * sxe_get_properties(zval *object TSRMLS_DC) /* {{{ */
+{
+   return sxe_get_prop_hash(object, 0 TSRMLS_CC);
+}
+/* }}} */
+
+static HashTable * sxe_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* 
{{{ */
+{
+   *is_temp = 1;
+   return sxe_get_prop_hash(object, 1 TSRMLS_CC);
+}
+/* }}} */
+
 static int sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC) /* {{{ 
*/
 {
php_sxe_object *sxe1;
@@ -1657,16 +1676,20 @@
 static int sxe_object_cast(zval *readobj, zval *writeobj, int type, void 
*extra TSRMLS_DC)
 {
php_sxe_object *sxe;
-   xmlChar   *contents = NULL;
+   xmlChar*contents = NULL;
xmlNodePtr  node;
-   int rv;
+   int rv;
+   HashTable  *prop_hash;
 
sxe = php_sxe_fetch_object(readobj TSRMLS_CC);

if (type == IS_BOOL) {
node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC);
+   prop_hash = sxe_get_prop_hash(readobj, 1 TSRMLS_CC);
INIT_PZVAL(writeobj);
-   ZVAL_BOOL(writeobj, node != NULL || 
zend_hash_num_elements(sxe_properties_get(readobj TSRMLS_CC))  0);
+   ZVAL_BOOL(writeobj, node != NULL || 
zend_hash_num_elements(prop_hash)  0);
+   zend_hash_destroy(prop_hash);
+   efree(prop_hash);
return SUCCESS;
}
 
@@ -1749,14 +1772,14 @@
sxe_property_write,
sxe_dimension_read,
sxe_dimension_write,
-   sxe_property_get_adr,
+   NULL,
sxe_get_value,  /* get */
NULL,
sxe_property_exists,
sxe_property_delete,
sxe_dimension_exists,
sxe_dimension_delete,
-   sxe_properties_get,
+   sxe_get_properties,
NULL, /* zend_get_std_object_handlers()-get_method,*/
NULL, /* zend_get_std_object_handlers()-call_method,*/
NULL, /* zend_get_std_object_handlers()-get_constructor, */
@@ -1764,7 +1787,8 @@
NULL, /* zend_get_std_object_handlers()-get_class_name,*/
sxe_objects_compare,
sxe_object_cast,
-   sxe_count_elements
+   sxe_count_elements,
+   sxe_get_debug_info
 };
 
 /* {{{ sxe_object_clone()
@@ -2372,7 +2396,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.226 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.227 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug39760.phpt

2006-12-30 Thread Rob Richards
rrichards   Sat Dec 30 15:42:24 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug39760.phpt 
  Log:
  MFB: fix bug #39760 (cloning fails on nested SimpleXML-Object)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.224r2=1.225diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.224 
php-src/ext/simplexml/simplexml.c:1.225
--- php-src/ext/simplexml/simplexml.c:1.224 Wed Nov 29 22:53:21 2006
+++ php-src/ext/simplexml/simplexml.c   Sat Dec 30 15:42:24 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.224 2006/11/29 22:53:21 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.225 2006/12/30 15:42:24 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1783,6 +1783,16 @@
clone-document-refcount++;
docp = clone-document-ptr;
}
+
+   clone-iter.isprefix = sxe-iter.isprefix;
+   if (sxe-iter.name != NULL) {
+   clone-iter.name = xmlStrdup((xmlChar *)sxe-iter.name);
+   }
+   if (sxe-iter.nsprefix != NULL) {
+   clone-iter.nsprefix = xmlStrdup((xmlChar *)sxe-iter.nsprefix);
+   }
+   clone-iter.type = sxe-iter.type;
+
if (sxe-node) {
nodep = xmlDocCopyNode(sxe-node-node, docp, 1);
}
@@ -2362,7 +2372,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.224 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.225 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug39760.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug39760.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug39760.phpt:1.2
--- /dev/null   Sat Dec 30 15:42:24 2006
+++ php-src/ext/simplexml/tests/bug39760.phpt   Sat Dec 30 15:42:24 2006
@@ -0,0 +1,55 @@
+--TEST--
+Bug #39760 (cloning fails on nested SimpleXML-Object)
+--SKIPIF--
+?php if (!extension_loaded(simplexml)) print skip simplexml extension is 
not loaded; ?
+--FILE--
+?php
+
+$xml = b'?xml version=1.0 ?
+test
+level1
+level2atext1/level2a
+level2btext2/level2b
+   /level1
+/test';
+$test = simplexml_load_string($xml);
+
+var_dump($test-level1-level2a);
+
+$test2 = clone $test;
+var_dump($test2-level1-level2a);
+
+$test3 = clone $test-level1-level2a;
+var_dump($test3);
+
+echo Done\n;
+?
+--EXPECTF--
+object(SimpleXMLElement)#%d (1) {
+  [0]=
+  string(5) text1
+}
+object(SimpleXMLElement)#%d (1) {
+  [0]=
+  string(5) text1
+}
+object(SimpleXMLElement)#%d (1) {
+  [0]=
+  string(5) text1
+}
+Done
+
+--UEXPECTF--   
+object(SimpleXMLElement)#%d (1) {
+  [0]=
+  unicode(5) text1
+}
+object(SimpleXMLElement)#%d (1) {
+  [0]=
+  unicode(5) text1
+}
+object(SimpleXMLElement)#%d (1) {
+  [0]=
+  unicode(5) text1
+}
+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 simplexml.c /ext/simplexml/tests bug39662.phpt

2006-11-29 Thread Rob Richards
rrichards   Wed Nov 29 08:52:09 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug39662.phpt 
  Log:
  MFB: correct fix for bug #39662 to fix leak and tree corruption
  fix test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.222r2=1.223diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.222 
php-src/ext/simplexml/simplexml.c:1.223
--- php-src/ext/simplexml/simplexml.c:1.222 Tue Nov 28 18:57:37 2006
+++ php-src/ext/simplexml/simplexml.c   Wed Nov 29 08:52:08 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.222 2006/11/28 18:57:37 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.223 2006/11/29 08:52:08 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1232,7 +1232,7 @@
}
}
 
-   if (XML_DOCUMENT_NODE == node-parent-type) {
+   if (node-parent  (XML_DOCUMENT_NODE == 
node-parent-type)) {
int bytes;
bytes = xmlSaveFile(filename, (xmlDocPtr) 
sxe-document-ptr);
if (bytes == -1) {
@@ -1265,7 +1265,7 @@
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
if (node) {
-   if (XML_DOCUMENT_NODE == node-parent-type) {
+   if (node-parent  (XML_DOCUMENT_NODE == node-parent-type)) {
xmlDocDumpMemory((xmlDocPtr) sxe-document-ptr, 
strval, strval_len);
RETVAL_STRINGL((char *)strval, strval_len, 1);
xmlFree(strval);
@@ -1784,7 +1784,6 @@
}
if (sxe-node) {
nodep = xmlDocCopyNode(sxe-node-node, docp, 1);
-   nodep-parent = sxe-node-node-parent;
}
 
php_libxml_increment_node_ptr((php_libxml_node_object *)clone, nodep, 
NULL TSRMLS_CC);
@@ -2362,7 +2361,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.222 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.223 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug39662.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug39662.phpt
diff -u php-src/ext/simplexml/tests/bug39662.phpt:1.1 
php-src/ext/simplexml/tests/bug39662.phpt:1.2
--- php-src/ext/simplexml/tests/bug39662.phpt:1.1   Tue Nov 28 18:57:37 2006
+++ php-src/ext/simplexml/tests/bug39662.phpt   Wed Nov 29 08:52:08 2006
@@ -31,11 +31,9 @@
 
 
 }
-string(55) ?xml version=1.0 encoding=utf-8?
-test
+string(15) test
 
-/test
-
+/test
 Done
 --UEXPECTF--
 object(SimpleXMLElement)#%d (1) {
@@ -50,9 +48,7 @@
 
 
 }
-string(55) ?xml version=1.0 encoding=utf-8?
-test
+string(15) test
 
-/test
-
+/test
 Done

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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug39662.phpt

2006-11-29 Thread Antony Dovgal

On 11/29/2006 11:52 AM, Rob Richards wrote:

rrichards   Wed Nov 29 08:52:09 2006 UTC

  Modified files:  
/php-src/ext/simplexml	simplexml.c 
/php-src/ext/simplexml/tests	bug39662.phpt 
  Log:

  MFB: correct fix for bug #39662 to fix leak and tree corruption
  fix test


Thanks, Rob.

--
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 /ext/simplexml simplexml.c

2006-11-29 Thread Antony Dovgal
tony2001Wed Nov 29 22:53:21 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  add missing folding marker
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.223r2=1.224diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.223 
php-src/ext/simplexml/simplexml.c:1.224
--- php-src/ext/simplexml/simplexml.c:1.223 Wed Nov 29 08:52:08 2006
+++ php-src/ext/simplexml/simplexml.c   Wed Nov 29 22:53:21 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.223 2006/11/29 08:52:08 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.224 2006/11/29 22:53:21 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1173,6 +1173,7 @@
 
xmlXPathFreeObject(retval);
 }
+/* }}} */
 
 /* {{{ proto bool SimpleXMLElement::registerXPathNamespace(string prefix, 
string ns) U
Creates a prefix/ns context for the next XPath query */
@@ -2361,7 +2362,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.223 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.224 $);
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 simplexml.c /ext/simplexml/tests bug39662.phpt

2006-11-28 Thread Antony Dovgal
tony2001Tue Nov 28 18:57:37 2006 UTC

  Added files: 
/php-src/ext/simplexml/testsbug39662.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fix #39662 (Segfault when calling asXML() of a cloned SimpleXMLElement)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.221r2=1.222diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.221 
php-src/ext/simplexml/simplexml.c:1.222
--- php-src/ext/simplexml/simplexml.c:1.221 Fri Oct 13 14:52:19 2006
+++ php-src/ext/simplexml/simplexml.c   Tue Nov 28 18:57:37 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.221 2006/10/13 14:52:19 andrei Exp $ */
+/* $Id: simplexml.c,v 1.222 2006/11/28 18:57:37 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1784,6 +1784,7 @@
}
if (sxe-node) {
nodep = xmlDocCopyNode(sxe-node-node, docp, 1);
+   nodep-parent = sxe-node-node-parent;
}
 
php_libxml_increment_node_ptr((php_libxml_node_object *)clone, nodep, 
NULL TSRMLS_CC);
@@ -2361,7 +2362,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.221 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.222 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug39662.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/bug39662.phpt
+++ php-src/ext/simplexml/tests/bug39662.phpt
--TEST--
Bug #39662 (Segfault when calling asXML() of a cloned SimpleXMLElement)
--SKIPIF--
?php if (!extension_loaded(simplexml)) print skip simplexml extension is 
not loaded; ?
--FILE--
?php

$xml = b'?xml version=1.0 encoding=utf-8 ?
test

/test';

$root = simplexml_load_string($xml);
$clone = clone $root;
var_dump($root);
var_dump($clone);
var_dump($clone-asXML());

echo Done\n;
?
--EXPECTF-- 
object(SimpleXMLElement)#%d (1) {
  [0]=
  string(2) 


}
object(SimpleXMLElement)#%d (1) {
  [0]=
  string(2) 


}
string(55) ?xml version=1.0 encoding=utf-8?
test

/test

Done
--UEXPECTF--
object(SimpleXMLElement)#%d (1) {
  [0]=
  unicode(2) 


}
object(SimpleXMLElement)#%d (1) {
  [0]=
  unicode(2) 


}
string(55) ?xml version=1.0 encoding=utf-8?
test

/test

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 simplexml.c

2006-09-06 Thread Nuno Lopes
nlopess Wed Sep  6 15:32:19 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  MFB
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.218r2=1.219diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.218 
php-src/ext/simplexml/simplexml.c:1.219
--- php-src/ext/simplexml/simplexml.c:1.218 Wed Aug 16 08:51:34 2006
+++ php-src/ext/simplexml/simplexml.c   Wed Sep  6 15:32:19 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.218 2006/08/16 08:51:34 sebastian Exp $ */
+/* $Id: simplexml.c,v 1.219 2006/09/06 15:32:19 nlopess Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1964,7 +1964,7 @@
 {
php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
char   *data, *ns = NULL;
-   int data_len, *ns_len = 0;
+   int data_len, ns_len = 0;
xmlDocPtr   docp;
longoptions = 0;
zend_bool   is_url = 0, isprefix = 0;
@@ -2339,7 +2339,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.218 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.219 $);
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 simplexml.c /ext/standard http_fopen_wrapper.c

2006-08-16 Thread Sebastian Bergmann
sebastian   Wed Aug 16 08:51:34 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/standard   http_fopen_wrapper.c 
  Log:
  Sync with php_trim() API change.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.217r2=1.218diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.217 
php-src/ext/simplexml/simplexml.c:1.218
--- php-src/ext/simplexml/simplexml.c:1.217 Mon Aug 14 11:58:49 2006
+++ php-src/ext/simplexml/simplexml.c   Wed Aug 16 08:51:34 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.217 2006/08/14 11:58:49 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.218 2006/08/16 08:51:34 sebastian Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -453,7 +453,7 @@
trim_zv = *member;
zval_copy_ctor(trim_zv);
convert_to_string_with_converter(trim_zv, 
UG(utf8_conv));
-   php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), NULL, 0, 
IS_STRING, tmp_zv, 3 TSRMLS_CC);
+   php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), NULL, 0, 
tmp_zv, 3 TSRMLS_CC);
zval_dtor(trim_zv);
member = tmp_zv;
}
@@ -2339,7 +2339,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.217 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.218 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.117r2=1.118diff_format=u
Index: php-src/ext/standard/http_fopen_wrapper.c
diff -u php-src/ext/standard/http_fopen_wrapper.c:1.117 
php-src/ext/standard/http_fopen_wrapper.c:1.118
--- php-src/ext/standard/http_fopen_wrapper.c:1.117 Thu Jun 29 14:42:30 2006
+++ php-src/ext/standard/http_fopen_wrapper.c   Wed Aug 16 08:51:34 2006
@@ -19,7 +19,7 @@
|  Sara Golemon [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: http_fopen_wrapper.c,v 1.117 2006/06/29 14:42:30 bjori Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.118 2006/08/16 08:51:34 sebastian Exp $ */ 
 
 #include php.h
 #include php_globals.h
@@ -350,7 +350,7 @@
Z_TYPE_PP(tmpzval) == IS_STRING  Z_STRLEN_PP(tmpzval)) {
/* Remove newlines and spaces from start and end,
   php_trim will estrndup() */
-   tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), 
NULL, 0, IS_STRING, NULL, 3 TSRMLS_CC);
+   tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), 
NULL, 0, NULL, 3 TSRMLS_CC);
if (strlen(tmp)  0) {
if (!header_init) { /* Remove post headers for 
redirects */
int l = strlen(tmp);
@@ -376,7 +376,7 @@
}
}
efree(tmp_c);
-   tmp_c = php_trim(tmp, strlen(tmp), NULL, 0, 
IS_STRING, NULL, 3 TSRMLS_CC);
+   tmp_c = php_trim(tmp, strlen(tmp), NULL, 0, 
NULL, 3 TSRMLS_CC);
efree(tmp);
tmp = tmp_c;
}

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests bug38424.phpt

2006-08-14 Thread Rob Richards
rrichards   Mon Aug 14 11:58:49 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/testsbug38424.phpt 
  Log:
  MFB: fix bug #38424 (Different attribute assignment if new or existing)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.216r2=1.217diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.216 
php-src/ext/simplexml/simplexml.c:1.217
--- php-src/ext/simplexml/simplexml.c:1.216 Tue Aug  8 20:52:45 2006
+++ php-src/ext/simplexml/simplexml.c   Mon Aug 14 11:58:49 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.216 2006/08/08 20:52:45 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.217 2006/08/14 11:58:49 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -366,6 +366,8 @@
 static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC)
 {
zval value_copy;
+   xmlChar *buffer;
+   int buffer_len;
 
if (!value)
{
@@ -386,7 +388,20 @@
convert_to_string_with_converter(value, UG(utf8_conv));
/* break missing intentionally */
case IS_STRING:
-   xmlNodeSetContentLen(node, (xmlChar 
*)Z_STRVAL_P(value), Z_STRLEN_P(value));
+   if (node-type == XML_ATTRIBUTE_NODE) {
+   buffer = xmlEncodeEntitiesReentrant(node-doc, 
(xmlChar *)Z_STRVAL_P(value));
+   buffer_len = xmlStrlen(buffer);
+   } else {
+   buffer = (xmlChar *)Z_STRVAL_P(value);
+   buffer_len = Z_STRLEN_P(value);
+   }
+   /* check for NULL buffer in case of memory error in 
xmlEncodeEntitiesReentrant */
+   if (buffer) {
+   xmlNodeSetContentLen(node, buffer, buffer_len);
+   if (node-type == XML_ATTRIBUTE_NODE) {
+   xmlFree(buffer);
+   }
+   }
if (value == value_copy) {
zval_dtor(value);
}
@@ -2324,7 +2339,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.216 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.217 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug38424.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/simplexml/tests/bug38424.phpt
diff -u /dev/null php-src/ext/simplexml/tests/bug38424.phpt:1.2
--- /dev/null   Mon Aug 14 11:58:49 2006
+++ php-src/ext/simplexml/tests/bug38424.phpt   Mon Aug 14 11:58:49 2006
@@ -0,0 +1,26 @@
+--TEST--
+Bug #38424 (Different attribute assignment if new or exists)
+--SKIPIF--
+?php if (!extension_loaded(simplexml)) print skip; ?
+--FILE--
+?php
+
+$xml = simplexml_load_string(b'xml/xml');
+
+$str = abc  def ;
+
+$xml[a1] =  ;
+$xml[a1] = htmlspecialchars($str,ENT_NOQUOTES) ;
+
+$xml[a2] = htmlspecialchars($str,ENT_NOQUOTES) ;
+
+$xml[a3] =  ;
+$xml[a3] = $str ;
+
+$xml[a4] = $str ;
+
+echo $xml-asXML();
+?
+--EXPECT-- 
+?xml version=1.0?
+xml a1=abc amp;amp; def a2=abc amp;amp; def a3=abc amp; def a4=abc 
amp; def/

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2006-08-06 Thread Antony Dovgal
tony2001Sun Aug  6 13:27:38 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  avoid extra strlen() call, we have the length of the data
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.210r2=1.211diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.210 
php-src/ext/simplexml/simplexml.c:1.211
--- php-src/ext/simplexml/simplexml.c:1.210 Mon Jun 26 15:36:45 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Aug  6 13:27:38 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.210 2006/06/26 15:36:45 bjori Exp $ */
+/* $Id: simplexml.c,v 1.211 2006/08/06 13:27:38 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1230,10 +1230,11 @@
xmlNodeDumpOutput(outbuf, (xmlDocPtr) 
sxe-document-ptr, node, 0, 1, ((xmlDocPtr) sxe-document-ptr)-encoding);
xmlOutputBufferFlush(outbuf);
strval = xmlStrndup(outbuf-buffer-content, 
outbuf-buffer-use);
+   strval_len = outbuf-buffer-use;
xmlOutputBufferClose(outbuf);
}
 
-   RETVAL_STRINGL(strval, strlen(strval), 1);
+   RETVAL_STRINGL(strval, strval_len, 1);
xmlFree(strval);
} else {
RETVAL_FALSE;
@@ -2264,7 +2265,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.210 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.211 $);
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 simplexml.c

2006-08-06 Thread Christian Stocker
chregu  Sun Aug  6 19:39:38 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fix #38354 (Unwanted reformatting of XML when using AsXML)   
  (MFB)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.212r2=1.213diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.212 
php-src/ext/simplexml/simplexml.c:1.213
--- php-src/ext/simplexml/simplexml.c:1.212 Sun Aug  6 17:41:39 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Aug  6 19:39:38 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.212 2006/08/06 17:41:39 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.213 2006/08/06 19:39:38 chregu Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1206,7 +1206,7 @@
RETURN_FALSE;
}
 
-   xmlNodeDumpOutput(outbuf, (xmlDocPtr) 
sxe-document-ptr, node, 0, 1, NULL);
+   xmlNodeDumpOutput(outbuf, (xmlDocPtr) 
sxe-document-ptr, node, 0, 0, NULL);
xmlOutputBufferClose(outbuf);
RETURN_TRUE;
}
@@ -1230,7 +1230,7 @@
RETURN_FALSE;
}
 
-   xmlNodeDumpOutput(outbuf, (xmlDocPtr) 
sxe-document-ptr, node, 0, 1, ((xmlDocPtr) sxe-document-ptr)-encoding);
+   xmlNodeDumpOutput(outbuf, (xmlDocPtr) 
sxe-document-ptr, node, 0, 0, ((xmlDocPtr) sxe-document-ptr)-encoding);
xmlOutputBufferFlush(outbuf);
strval = xmlStrndup(outbuf-buffer-content, 
outbuf-buffer-use);
strval_len = outbuf-buffer-use;
@@ -2268,7 +2268,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.212 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.213 $);
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 simplexml.c

2006-05-23 Thread Marcus Boerger
helly   Tue May 23 21:37:18 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Fix SEGV in case class to generate is not derived from SimpleXMLElement
by issueing an error
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.207r2=1.208diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.207 
php-src/ext/simplexml/simplexml.c:1.208
--- php-src/ext/simplexml/simplexml.c:1.207 Wed May 17 00:07:05 2006
+++ php-src/ext/simplexml/simplexml.c   Tue May 23 21:37:17 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.207 2006/05/17 00:07:05 helly Exp $ */
+/* $Id: simplexml.c,v 1.208 2006/05/23 21:37:17 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1830,13 +1830,13 @@
char   *filename;
int filename_len;
xmlDocPtr   docp;
-   char   *classname = NULL, *ns = NULL;
-   int classname_len = 0, ns_len = 0;
+   char   *ns = NULL;
+   int ns_len = 0;
longoptions = 0;
zend_class_entry *ce= sxe_class_entry;
zend_bool   isprefix = 0;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|slsb, 
filename, filename_len, classname, classname_len, options, ns, ns_len, 
isprefix) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|Clsb, 
filename, filename_len, ce, options, ns, ns_len, isprefix) == FAILURE) {
return;
}
 
@@ -1846,14 +1846,6 @@
RETURN_FALSE;
}
 
-   if (classname_len) {
-   zend_class_entry **pce;
-   if (zend_lookup_class(classname, classname_len, pce TSRMLS_CC) 
== FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_ERROR, Class %s 
does not exist, classname);
-   }
-   ce = *pce;
-   }
-
sxe = php_sxe_object_new(ce TSRMLS_CC);
sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
sxe-iter.isprefix = isprefix;
@@ -1873,13 +1865,13 @@
char   *data;
int data_len;
xmlDocPtr   docp;
-   char   *classname = NULL, *ns = NULL;
-   int classname_len = 0, ns_len = 0;
+   char   *ns = NULL;
+   int ns_len = 0;
longoptions = 0;
zend_class_entry *ce= sxe_class_entry;
zend_bool   isprefix = 0;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|slsb, data, 
data_len, classname, classname_len, options, ns, ns_len, isprefix) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|Clsb, data, 
data_len, ce, options, ns, ns_len, isprefix) == FAILURE) {
return;
}
 
@@ -1889,14 +1881,6 @@
RETURN_FALSE;
}
 
-   if (classname_len) {
-   zend_class_entry **pce;
-   if (zend_lookup_class(classname, classname_len, pce TSRMLS_CC) 
== FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_ERROR, Class %s 
does not exist, classname);
-   }
-   ce = *pce;
-   }
-
sxe = php_sxe_object_new(ce TSRMLS_CC);
sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
sxe-iter.isprefix = isprefix;
@@ -2144,11 +2128,9 @@
zval *node;
php_libxml_node_object *object;
xmlNodePtr  nodep = NULL;
-   char   *classname = ;
-   int classname_len = 0;
zend_class_entry *ce= sxe_class_entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, o|s, node, 
classname, classname_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, o|C, node, ce) 
== FAILURE) {
return;
}
 
@@ -2167,14 +2149,6 @@
}
 
if (nodep  nodep-type == XML_ELEMENT_NODE) {
-   if (classname_len) {
-   zend_class_entry **pce;
-   if (zend_lookup_class(classname, classname_len, pce 
TSRMLS_CC) == FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_ERROR, 
Class %s does not exist, classname);
-   }
-   ce = *pce;
-   }
-
sxe = php_sxe_object_new(ce TSRMLS_CC);
sxe-document = object-document;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, 
nodep-doc TSRMLS_CC);
@@ -2279,7 +2253,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.207 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.208 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2006-05-23 Thread Marcus Boerger
helly   Tue May 23 22:22:35 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Readd NULL as allowed classname to skip parameter
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.208r2=1.209diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.208 
php-src/ext/simplexml/simplexml.c:1.209
--- php-src/ext/simplexml/simplexml.c:1.208 Tue May 23 21:37:17 2006
+++ php-src/ext/simplexml/simplexml.c   Tue May 23 22:22:35 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.208 2006/05/23 21:37:17 helly Exp $ */
+/* $Id: simplexml.c,v 1.209 2006/05/23 22:22:35 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1836,7 +1836,7 @@
zend_class_entry *ce= sxe_class_entry;
zend_bool   isprefix = 0;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|Clsb, 
filename, filename_len, ce, options, ns, ns_len, isprefix) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|C!lsb, 
filename, filename_len, ce, options, ns, ns_len, isprefix) == FAILURE) {
return;
}
 
@@ -1846,6 +1846,9 @@
RETURN_FALSE;
}
 
+   if (!ce) {
+   ce = sxe_class_entry;
+   }
sxe = php_sxe_object_new(ce TSRMLS_CC);
sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
sxe-iter.isprefix = isprefix;
@@ -1871,7 +1874,7 @@
zend_class_entry *ce= sxe_class_entry;
zend_bool   isprefix = 0;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|Clsb, data, 
data_len, ce, options, ns, ns_len, isprefix) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|C!lsb, data, 
data_len, ce, options, ns, ns_len, isprefix) == FAILURE) {
return;
}
 
@@ -1881,6 +1884,9 @@
RETURN_FALSE;
}
 
+   if (!ce) {
+   ce = sxe_class_entry;
+   }
sxe = php_sxe_object_new(ce TSRMLS_CC);
sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
sxe-iter.isprefix = isprefix;
@@ -2130,7 +2136,7 @@
xmlNodePtr  nodep = NULL;
zend_class_entry *ce= sxe_class_entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, o|C, node, ce) 
== FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, o|C!, node, 
ce) == FAILURE) {
return;
}
 
@@ -2149,6 +2155,9 @@
}
 
if (nodep  nodep-type == XML_ELEMENT_NODE) {
+   if (!ce) {
+   ce = sxe_class_entry;
+   }
sxe = php_sxe_object_new(ce TSRMLS_CC);
sxe-document = object-document;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, 
nodep-doc TSRMLS_CC);
@@ -2253,7 +2262,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.208 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.209 $);
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 simplexml.c

2006-05-16 Thread Marcus Boerger
helly   Wed May 17 00:07:05 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Proto fix/add
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.206r2=1.207diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.206 
php-src/ext/simplexml/simplexml.c:1.207
--- php-src/ext/simplexml/simplexml.c:1.206 Fri Apr 14 15:15:21 2006
+++ php-src/ext/simplexml/simplexml.c   Wed May 17 00:07:05 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.206 2006/04/14 15:15:21 helly Exp $ */
+/* $Id: simplexml.c,v 1.207 2006/05/17 00:07:05 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1055,7 +1055,7 @@
 }
 /* }}} */
 
-/* {{{ array SimpleXMLElement::xpath(string path)
+/* {{{ proto array SimpleXMLElement::xpath(string path)
Runs XPath query on the XML data */
 SXE_METHOD(xpath)
 {
@@ -1142,6 +1142,8 @@
xmlXPathFreeObject(retval);
 }
 
+/* {{{ proto bool SimpleXMLElement::registerXPathNamespace(string prefix, 
string ns)
+   Creates a prefix/ns context for the next XPath query */
 SXE_METHOD(registerXPathNamespace)
 {
php_sxe_object*sxe;
@@ -2277,7 +2279,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.206 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.207 $);
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 simplexml.c

2006-04-14 Thread Marcus Boerger
helly   Fri Apr 14 12:18:15 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - If node no longer exists then there won't be any data
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.203r2=1.204diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.203 
php-src/ext/simplexml/simplexml.c:1.204
--- php-src/ext/simplexml/simplexml.c:1.203 Mon Apr 10 23:19:23 2006
+++ php-src/ext/simplexml/simplexml.c   Fri Apr 14 12:18:15 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.203 2006/04/10 23:19:23 helly Exp $ */
+/* $Id: simplexml.c,v 1.204 2006/04/14 12:18:15 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -950,6 +950,9 @@
}
 
GET_NODE(sxe, node);
+   if (!node) {
+   return rv;
+   }
if (1||sxe-iter.type != SXE_ITER_CHILD) {
if (sxe-iter.type == SXE_ITER_ELEMENT) {
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
@@ -2261,7 +2264,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.203 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.204 $);
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 simplexml.c /ext/simplexml/tests profile12.phpt

2006-04-14 Thread Marcus Boerger
helly   Fri Apr 14 14:07:51 2006 UTC

  Added files: 
/php-src/ext/simplexml/testsprofile12.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Allow access to namespaced root by specifying prefix on creation
  - Fix access to non namespaced root
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.204r2=1.205diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.204 
php-src/ext/simplexml/simplexml.c:1.205
--- php-src/ext/simplexml/simplexml.c:1.204 Fri Apr 14 12:18:15 2006
+++ php-src/ext/simplexml/simplexml.c   Fri Apr 14 14:07:51 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.204 2006/04/14 12:18:15 helly Exp $ */
+/* $Id: simplexml.c,v 1.205 2006/04/14 14:07:51 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -69,7 +69,7 @@
if (name) {
subnode-iter.name = xmlStrdup(name);
}
-   if (prefix) {
+   if (prefix  *prefix) {
subnode-iter.nsprefix = xmlStrdup(prefix);
}
 
@@ -122,7 +122,7 @@
return 1;
}
 
-   if (node-ns  !xmlStrcmp(node-ns-href, name)) {
+   if (node-ns  (/*!xmlStrcmp(node-ns-prefix, name) ||*/ 
!xmlStrcmp(node-ns-href, name))) {
return 1;
}
 
@@ -1816,7 +1816,7 @@
 }
 /* }}} */
 
-/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string 
class_name [, int options]])
+/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string 
class_name [, int options [, string ns]]])
Load a filename and return a simplexml_element object to allow for 
processing */
 PHP_FUNCTION(simplexml_load_file)
 {
@@ -1824,12 +1824,12 @@
char   *filename;
int filename_len;
xmlDocPtr   docp;
-   char   *classname = ;
-   int classname_len = 0;
+   char   *classname = NULL, *ns = NULL;
+   int classname_len = 0, ns_len = 0;
longoptions = 0;
zend_class_entry *ce= sxe_class_entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, filename, 
filename_len, classname, classname_len, options) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, 
filename, filename_len, classname, classname_len, options, ns, ns_len) 
== FAILURE) {
return;
}
 
@@ -1848,6 +1848,7 @@
}
 
sxe = php_sxe_object_new(ce TSRMLS_CC);
+   sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp 
TSRMLS_CC);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
xmlDocGetRootElement(docp), NULL TSRMLS_CC);
 
@@ -1856,7 +1857,7 @@
 }
 /* }}} */
 
-/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name [, int options]])
+/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name [, int options [, string ns]]])
Load a string and return a simplexml_element object to allow for processing 
*/
 PHP_FUNCTION(simplexml_load_string)
 {
@@ -1864,12 +1865,12 @@
char   *data;
int data_len;
xmlDocPtr   docp;
-   char   *classname = ;
-   int classname_len = 0;
+   char   *classname = NULL, *ns = NULL;
+   int classname_len = 0, ns_len = 0;
longoptions = 0;
zend_class_entry *ce= sxe_class_entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, data, 
data_len, classname, classname_len, options) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, data, 
data_len, classname, classname_len, options, ns, ns_len) == FAILURE) {
return;
}
 
@@ -1888,6 +1889,7 @@
}
 
sxe = php_sxe_object_new(ce TSRMLS_CC);
+   sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp 
TSRMLS_CC);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
xmlDocGetRootElement(docp), NULL TSRMLS_CC);
 
@@ -1897,19 +1899,19 @@
 /* }}} */
 
 
-/* {{{ proto SimpleXMLElement::__construct(string data [, int options [, bool 
data_is_url]])
+/* {{{ proto SimpleXMLElement::__construct(string data [, int options [, bool 
data_is_url [, string ns]]])
SimpleXMLElement constructor */
 SXE_METHOD(__construct)
 {
php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
-   char   *data;
-   int data_len;
+   char   *data, *ns = NULL;
+   int data_len, *ns_len = 0;
xmlDocPtr   docp;
longoptions = 0;
zend_bool   is_url = 0;
 
  

Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests profile12.phpt

2006-04-14 Thread Rob Richards

Hi Marcus,

I think it would be better to speficy namespace URI rather than prefix. 
Prefix can be anything, so unless you know what was used, you need to 
use the new namespace methods (which are primarily debug functions). It 
is more common to known the URI than prefix.


I havent tried the changes yet, but is it required to specify the 
namespace for a document element in a namespace or when loading does it 
automatically set the namespace scope based on the namespace of the doc 
element?


Rob

Marcus Boerger wrote:


helly   Fri Apr 14 14:07:51 2006 UTC

 Added files: 
   /php-src/ext/simplexml/tests	profile12.phpt 

 Modified files:  
   /php-src/ext/simplexml	simplexml.c 
 Log:

 - Allow access to namespaced root by specifying prefix on creation
 - Fix access to non namespaced root
 
 
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.204r2=1.205diff_format=u

Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.204 
php-src/ext/simplexml/simplexml.c:1.205
--- php-src/ext/simplexml/simplexml.c:1.204 Fri Apr 14 12:18:15 2006
+++ php-src/ext/simplexml/simplexml.c   Fri Apr 14 14:07:51 2006
@@ -18,7 +18,7 @@
  +--+
*/

-/* $Id: simplexml.c,v 1.204 2006/04/14 12:18:15 helly Exp $ */
+/* $Id: simplexml.c,v 1.205 2006/04/14 14:07:51 helly Exp $ */

#ifdef HAVE_CONFIG_H
#include config.h
@@ -69,7 +69,7 @@
if (name) {
subnode-iter.name = xmlStrdup(name);
}
-   if (prefix) {
+   if (prefix  *prefix) {
subnode-iter.nsprefix = xmlStrdup(prefix);
}

@@ -122,7 +122,7 @@
return 1;
}

-   if (node-ns  !xmlStrcmp(node-ns-href, name)) {
+   if (node-ns  (/*!xmlStrcmp(node-ns-prefix, name) ||*/ 
!xmlStrcmp(node-ns-href, name))) {
return 1;
}

@@ -1816,7 +1816,7 @@
}
/* }}} */

-/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string 
class_name [, int options]])
+/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string 
class_name [, int options [, string ns]]])
   Load a filename and return a simplexml_element object to allow for 
processing */
PHP_FUNCTION(simplexml_load_file)
{
@@ -1824,12 +1824,12 @@
char   *filename;
int filename_len;
xmlDocPtr   docp;
-   char   *classname = ;
-   int classname_len = 0;
+   char   *classname = NULL, *ns = NULL;
+   int classname_len = 0, ns_len = 0;
longoptions = 0;
zend_class_entry *ce= sxe_class_entry;

-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, filename, 
filename_len, classname, classname_len, options) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, filename, filename_len, 
classname, classname_len, options, ns, ns_len) == FAILURE) {
return;
}

@@ -1848,6 +1848,7 @@
}

sxe = php_sxe_object_new(ce TSRMLS_CC);
+   sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp 
TSRMLS_CC);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
xmlDocGetRootElement(docp), NULL TSRMLS_CC);

@@ -1856,7 +1857,7 @@
}
/* }}} */

-/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name [, int options]])
+/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name [, int options [, string ns]]])
   Load a string and return a simplexml_element object to allow for processing 
*/
PHP_FUNCTION(simplexml_load_string)
{
@@ -1864,12 +1865,12 @@
char   *data;
int data_len;
xmlDocPtr   docp;
-   char   *classname = ;
-   int classname_len = 0;
+   char   *classname = NULL, *ns = NULL;
+   int classname_len = 0, ns_len = 0;
longoptions = 0;
zend_class_entry *ce= sxe_class_entry;

-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, data, data_len, 
classname, classname_len, options) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, data, data_len, 
classname, classname_len, options, ns, ns_len) == FAILURE) {
return;
}

@@ -1888,6 +1889,7 @@
}

sxe = php_sxe_object_new(ce TSRMLS_CC);
+   sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp 
TSRMLS_CC);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
xmlDocGetRootElement(docp), NULL TSRMLS_CC);

@@ -1897,19 +1899,19 @@
/* }}} */


-/* {{{ proto SimpleXMLElement::__construct(string data [, int options [, bool 
data_is_url]])
+/* {{{ proto 

Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests profile12.phpt

2006-04-14 Thread Adam Maccabee Trachtenberg
I think using namespace URI will also help us out with default
namespaces because they don't have a ns prefix.

-adam

On Fri, 14 Apr 2006, Rob Richards wrote:

 Hi Marcus,

 I think it would be better to speficy namespace URI rather than prefix.
 Prefix can be anything, so unless you know what was used, you need to
 use the new namespace methods (which are primarily debug functions). It
 is more common to known the URI than prefix.

 I havent tried the changes yet, but is it required to specify the
 namespace for a document element in a namespace or when loading does it
 automatically set the namespace scope based on the namespace of the doc
 element?

 Rob

 Marcus Boerger wrote:

 hellyFri Apr 14 14:07:51 2006 UTC
 
   Added files:
 /php-src/ext/simplexml/tests profile12.phpt
 
   Modified files:
 /php-src/ext/simplexml   simplexml.c
   Log:
   - Allow access to namespaced root by specifying prefix on creation
   - Fix access to non namespaced root
 
 
 http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.204r2=1.205diff_format=u
 Index: php-src/ext/simplexml/simplexml.c
 diff -u php-src/ext/simplexml/simplexml.c:1.204 
 php-src/ext/simplexml/simplexml.c:1.205
 --- php-src/ext/simplexml/simplexml.c:1.204  Fri Apr 14 12:18:15 2006
 +++ php-src/ext/simplexml/simplexml.cFri Apr 14 14:07:51 2006
 @@ -18,7 +18,7 @@
+--+
  */
 
 -/* $Id: simplexml.c,v 1.204 2006/04/14 12:18:15 helly Exp $ */
 +/* $Id: simplexml.c,v 1.205 2006/04/14 14:07:51 helly Exp $ */
 
  #ifdef HAVE_CONFIG_H
  #include config.h
 @@ -69,7 +69,7 @@
  if (name) {
  subnode-iter.name = xmlStrdup(name);
  }
 -if (prefix) {
 +if (prefix  *prefix) {
  subnode-iter.nsprefix = xmlStrdup(prefix);
  }
 
 @@ -122,7 +122,7 @@
  return 1;
  }
 
 -if (node-ns  !xmlStrcmp(node-ns-href, name)) {
 +if (node-ns  (/*!xmlStrcmp(node-ns-prefix, name) ||*/ 
 !xmlStrcmp(node-ns-href, name))) {
  return 1;
  }
 
 @@ -1816,7 +1816,7 @@
  }
  /* }}} */
 
 -/* {{{ proto simplemxml_element simplexml_load_file(string filename [, 
 string class_name [, int options]])
 +/* {{{ proto simplemxml_element simplexml_load_file(string filename [, 
 string class_name [, int options [, string ns]]])
 Load a filename and return a simplexml_element object to allow for 
  processing */
  PHP_FUNCTION(simplexml_load_file)
  {
 @@ -1824,12 +1824,12 @@
  char   *filename;
  int filename_len;
  xmlDocPtr   docp;
 -char   *classname = ;
 -int classname_len = 0;
 +char   *classname = NULL, *ns = NULL;
 +int classname_len = 0, ns_len = 0;
  longoptions = 0;
  zend_class_entry *ce= sxe_class_entry;
 
 -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, filename, 
 filename_len, classname, classname_len, options) == FAILURE) {
 +if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, 
 filename, filename_len, classname, classname_len, options, ns, 
 ns_len) == FAILURE) {
  return;
  }
 
 @@ -1848,6 +1848,7 @@
  }
 
  sxe = php_sxe_object_new(ce TSRMLS_CC);
 +sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
  php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp 
  TSRMLS_CC);
  php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
  xmlDocGetRootElement(docp), NULL TSRMLS_CC);
 
 @@ -1856,7 +1857,7 @@
  }
  /* }}} */
 
 -/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
 class_name [, int options]])
 +/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
 class_name [, int options [, string ns]]])
 Load a string and return a simplexml_element object to allow for 
  processing */
  PHP_FUNCTION(simplexml_load_string)
  {
 @@ -1864,12 +1865,12 @@
  char   *data;
  int data_len;
  xmlDocPtr   docp;
 -char   *classname = ;
 -int classname_len = 0;
 +char   *classname = NULL, *ns = NULL;
 +int classname_len = 0, ns_len = 0;
  longoptions = 0;
  zend_class_entry *ce= sxe_class_entry;
 
 -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, data, 
 data_len, classname, classname_len, options) == FAILURE) {
 +if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, data, 
 data_len, classname, classname_len, options, ns, ns_len) == FAILURE) {
  return;
  }
 
 @@ -1888,6 +1889,7 @@
  }
 
  sxe = php_sxe_object_new(ce TSRMLS_CC);
 +sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
  php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp 
  TSRMLS_CC);
  php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
  xmlDocGetRootElement(docp), NULL TSRMLS_CC);
 
 @@ -1897,19 

Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests profile12.phpt

2006-04-14 Thread Marcus Boerger
Hello Rob,

  actually the comment was wrong/premature. This part of todays changes
only allows the URI to be specified. The prefix stuff comes later. And
well the prefix stuff is only a convenient stuff if you know what you do.
And yes you are right only the URI is unique but not all people know this
or even use XML in that manner.

best regards
marcus

Friday, April 14, 2006, 5:44:44 PM, you wrote:

 Hi Marcus,

 I think it would be better to speficy namespace URI rather than prefix. 
 Prefix can be anything, so unless you know what was used, you need to 
 use the new namespace methods (which are primarily debug functions). It 
 is more common to known the URI than prefix.

 I havent tried the changes yet, but is it required to specify the 
 namespace for a document element in a namespace or when loading does it 
 automatically set the namespace scope based on the namespace of the doc 
 element?

 Rob

 Marcus Boerger wrote:

helly  Fri Apr 14 14:07:51 2006 UTC

  Added files: 
/php-src/ext/simplexml/tests   profile12.phpt 

  Modified files:  
/php-src/ext/simplexml simplexml.c 
  Log:
  - Allow access to namespaced root by specifying prefix on creation
  - Fix access to non namespaced root
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.204r2=1.205diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.204 
php-src/ext/simplexml/simplexml.c:1.205
--- php-src/ext/simplexml/simplexml.c:1.204Fri Apr 14 12:18:15 2006
+++ php-src/ext/simplexml/simplexml.c  Fri Apr 14 14:07:51 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.204 2006/04/14 12:18:15 helly Exp $ */
+/* $Id: simplexml.c,v 1.205 2006/04/14 14:07:51 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -69,7 +69,7 @@
   if (name) {
   subnode-iter.name = xmlStrdup(name);
   }
-  if (prefix) {
+  if (prefix  *prefix) {
   subnode-iter.nsprefix = xmlStrdup(prefix);
   }
 
@@ -122,7 +122,7 @@
   return 1;
   }
 
-  if (node-ns  !xmlStrcmp(node-ns-href, name)) {
+  if (node-ns  (/*!xmlStrcmp(node-ns-prefix, name) ||*/ 
!xmlStrcmp(node-ns-href, name))) {
   return 1;
   }
 
@@ -1816,7 +1816,7 @@
 }
 /* }}} */
 
-/* {{{ proto simplemxml_element simplexml_load_file(string filename [, 
string class_name [, int options]])
+/* {{{ proto simplemxml_element simplexml_load_file(string filename [, 
string class_name [, int options [, string ns]]])
Load a filename and return a simplexml_element object to allow for 
 processing */
 PHP_FUNCTION(simplexml_load_file)
 {
@@ -1824,12 +1824,12 @@
   char   *filename;
   int filename_len;
   xmlDocPtr   docp;
-  char   *classname = ;
-  int classname_len = 0;
+  char   *classname = NULL, *ns = NULL;
+  int classname_len = 0, ns_len = 0;
   longoptions = 0;
   zend_class_entry *ce= sxe_class_entry;
 
-  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, 
filename, filename_len, classname, classname_len, options) == FAILURE) {
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, 
filename, filename_len, classname, classname_len, options, ns, ns_len) 
== FAILURE) {
   return;
   }
 
@@ -1848,6 +1848,7 @@
   }
 
   sxe = php_sxe_object_new(ce TSRMLS_CC);
+  sxe-iter.nsprefix = ns_len ? xmlStrdup(ns) : NULL;
   php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp 
 TSRMLS_CC);
   php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
 xmlDocGetRootElement(docp), NULL TSRMLS_CC);
 
@@ -1856,7 +1857,7 @@
 }
 /* }}} */
 
-/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name [, int options]])
+/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name [, int options [, string ns]]])
Load a string and return a simplexml_element object to allow for 
 processing */
 PHP_FUNCTION(simplexml_load_string)
 {
@@ -1864,12 +1865,12 @@
   char   *data;
   int data_len;
   xmlDocPtr   docp;
-  char   *classname = ;
-  int classname_len = 0;
+  char   *classname = NULL, *ns = NULL;
+  int classname_len = 0, ns_len = 0;
   longoptions = 0;
   zend_class_entry *ce= sxe_class_entry;
 
-  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, data, 
data_len, classname, classname_len, options) == FAILURE) {
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sls, data, 
data_len, classname, classname_len, options, ns, ns_len) == FAILURE) {
   return;
   }
 
@@ -1888,6 +1889,7 @@
   }
 
   sxe = php_sxe_object_new(ce TSRMLS_CC);
+  

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2006-04-10 Thread Marcus Boerger
helly   Mon Apr 10 23:19:23 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Coverity issue 59
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.202r2=1.203diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.202 
php-src/ext/simplexml/simplexml.c:1.203
--- php-src/ext/simplexml/simplexml.c:1.202 Wed Mar 29 15:08:52 2006
+++ php-src/ext/simplexml/simplexml.c   Mon Apr 10 23:19:23 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.202 2006/03/29 15:08:52 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.203 2006/04/10 23:19:23 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -2055,6 +2055,9 @@
if (intern != NULL  intern-node != NULL) {
curnode = (xmlNodePtr)((php_libxml_node_ptr 
*)intern-node)-node;
}
+   if (!curnode) {
+   return HASH_KEY_NON_EXISTANT;
+   }
 
if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
@@ -2258,7 +2261,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.202 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.203 $);
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 simplexml.c /ext/simplexml/tests 031.phpt

2006-03-06 Thread Rob Richards
rrichards   Mon Mar  6 20:16:03 2006 UTC

  Added files: 
/php-src/ext/simplexml/tests031.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  implement addChild() and addAttribute() methods
  add test
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.199r2=1.200diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.199 
php-src/ext/simplexml/simplexml.c:1.200
--- php-src/ext/simplexml/simplexml.c:1.199 Sun Mar  5 15:58:09 2006
+++ php-src/ext/simplexml/simplexml.c   Mon Mar  6 20:16:03 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.199 2006/03/05 15:58:09 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.200 2006/03/06 20:16:03 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -751,10 +751,10 @@
php_sxe_object *sxe;
xmlNodePtr  node;
xmlNodePtr  nnext;
-   xmlAttrPtr  attr;
+   xmlAttrPtr  attr = NULL;
xmlAttrPtr  anext;
zvaltmp_zv;
-   int test;
+   int test = 0;
 
if (Z_TYPE_P(member) != IS_STRING  Z_TYPE_P(member) != IS_LONG) {
tmp_zv = *member;
@@ -1411,6 +1411,129 @@
 }
 /* }}} */
 
+/* {{{ proto void SimpleXMLElement::addChild(string qName [, string value 
[,string ns]])
+   Add Element with optional namespace information */
+SXE_METHOD(addChild)
+{
+   php_sxe_object *sxe;
+   char   *qname, *value = NULL, *nsuri = NULL;
+   int qname_len, value_len = 0, nsuri_len = 0;
+   xmlNodePtr  node, newnode;
+   xmlNsPtrnsptr = NULL;
+   xmlChar*localname, *prefix = NULL;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|s!s!,
+   qname, qname_len, value, value_len, nsuri, nsuri_len) == 
FAILURE) {
+   return;
+   }
+
+   if (qname_len == 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Element name is 
required);
+   return;
+   }
+
+   sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+   GET_NODE(sxe, node);
+
+   if (sxe-iter.type == SXE_ITER_ATTRLIST) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot add element 
to attributes);
+   return;
+   }
+
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+
+   localname = xmlSplitQName2(qname, prefix);
+   if (localname == NULL) {
+   localname = xmlStrdup(qname);
+   }
+
+
+   newnode = xmlNewChild(node, NULL, localname, value);
+
+   if (nsuri != NULL) {
+   nsptr = xmlSearchNsByHref(node-doc, node, nsuri);
+   if (nsptr == NULL) {
+   nsptr = xmlNewNs(newnode, nsuri, prefix);
+   }
+   newnode-ns = nsptr;
+   }
+
+   _node_as_zval(sxe, newnode, return_value, SXE_ITER_NONE, localname, 
prefix TSRMLS_CC);
+
+   xmlFree(localname);
+   if (prefix != NULL) {
+   xmlFree(prefix);
+   }
+}
+/* }}} */
+
+/* {{{ proto void SimpleXMLElement::addAttribute(string qName, string value 
[,string ns])
+   Add Attribute with optional namespace information */
+SXE_METHOD(addAttribute)
+{
+   php_sxe_object *sxe;
+   char   *qname, *value = NULL, *nsuri = NULL;
+   int qname_len, value_len = 0, nsuri_len = 0;
+   xmlNodePtr  node;
+   xmlAttrPtr  attrp = NULL;
+   xmlNsPtrnsptr = NULL;
+   xmlChar*localname, *prefix = NULL;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|s!,
+   qname, qname_len, value, value_len, nsuri, nsuri_len) == 
FAILURE) {
+   return;
+   }
+
+   if (qname_len == 0 || value_len == 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Attribute name and 
value are required);
+   return;
+   }
+
+   sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+   GET_NODE(sxe, node);
+
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+
+   if (node-type != XML_ELEMENT_NODE) {
+   node = node-parent;
+   }
+
+   if (node == NULL) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to locate 
parent Element);
+   return;
+   }
+
+   localname = xmlSplitQName2(qname, prefix);
+   if (localname == NULL) {
+   localname = xmlStrdup(qname);
+   }
+
+   attrp = xmlHasNsProp(node, localname, nsuri);
+   if (attrp != NULL  attrp-type != XML_ATTRIBUTE_DECL) {
+   xmlFree(localname);
+   if (prefix != NULL) {
+   xmlFree(prefix);
+   }
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Attribute already 
exists);
+   return;
+   }
+
+   if 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 027.phpt 030.phpt bug35785.phpt

2006-03-05 Thread Rob Richards
rrichards   Sun Mar  5 14:01:13 2006 UTC

  Added files: 
/php-src/ext/simplexml/tests030.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests027.phpt bug35785.phpt 
  Log:
  fix crash passing non-string member to sxe_prop_dim_exists
  allow offsets to be used when calling isset/unset
  fix tests
  add test
  http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.197r2=1.198diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.197 
php-src/ext/simplexml/simplexml.c:1.198
--- php-src/ext/simplexml/simplexml.c:1.197 Thu Mar  2 13:12:45 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Mar  5 14:01:13 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.197 2006/03/02 13:12:45 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.198 2006/03/05 14:01:13 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -626,6 +626,14 @@
xmlAttrPtr  attr = NULL;
int exists = 0;
int test = 0;
+   zvaltmp_zv;
+
+   if (Z_TYPE_P(member) != IS_STRING  Z_TYPE_P(member) != IS_LONG) {
+   tmp_zv = *member;
+   zval_copy_ctor(tmp_zv);
+   member = tmp_zv;
+   convert_to_string(member);
+   }
 
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
@@ -655,13 +663,28 @@
 
if (node) {
if (attribs) {
-   while (attr) {
-   if ((!test || !xmlStrcmp(attr-name, 
sxe-iter.name))  !xmlStrcmp(attr-name, Z_STRVAL_P(member))  match_ns(sxe, 
(xmlNodePtr) attr, sxe-iter.nsprefix)) {
-   exists = 1;
-   break;
+   if (Z_TYPE_P(member) == IS_LONG) {
+   int nodendx = 0;
+
+   while (attr  nodendx = Z_LVAL_P(member)) {
+   if ((!test || !xmlStrcmp(attr-name, 
sxe-iter.name))  match_ns(sxe, (xmlNodePtr) attr, sxe-iter.nsprefix)) {
+   if (nodendx == 
Z_LVAL_P(member)) {
+   exists = 1;
+   break;
+   }
+   nodendx++;
+   }
+   attr = attr-next;
}
+   } else {
+   while (attr) {
+   if ((!test || !xmlStrcmp(attr-name, 
sxe-iter.name))  !xmlStrcmp(attr-name, Z_STRVAL_P(member))  match_ns(sxe, 
(xmlNodePtr) attr, sxe-iter.nsprefix)) {
+   exists = 1;
+   break;
+   }
 
-   attr = attr-next;
+   attr = attr-next;
+   }
}
}
 
@@ -673,14 +696,6 @@
node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node, NULL);
}
else {
-   zval tmp_zv;
-
-   if (Z_TYPE_P(member) != IS_STRING) {
-   tmp_zv = *member;
-   zval_copy_ctor(tmp_zv);
-   member = tmp_zv;
-   convert_to_string(member);
-   }
node = node-children;
while (node) {
xmlNodePtr nnext;
@@ -690,9 +705,6 @@
}
node = nnext;
}
-   if (member == tmp_zv) {
-   zval_dtor(tmp_zv);
-   }
}
if (node) {
exists = 1;
@@ -700,6 +712,10 @@
}
}
 
+   if (member == tmp_zv) {
+   zval_dtor(tmp_zv);
+   }
+
return exists;
 }
 /* }}} */
@@ -732,7 +748,7 @@
zvaltmp_zv;
int test;
 
-   if (Z_TYPE_P(member) != IS_STRING) {
+   if (Z_TYPE_P(member) != IS_STRING  Z_TYPE_P(member) != IS_LONG) {
tmp_zv = *member;
zval_copy_ctor(tmp_zv);
member = tmp_zv;
@@ -742,13 +758,24 @@
sxe = 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2006-03-05 Thread Antony Dovgal
tony2001Sun Mar  5 15:58:09 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  MF51: fix #36611 (assignment to SimpleXML object attribute changes argument 
type to string)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.198r2=1.199diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.198 
php-src/ext/simplexml/simplexml.c:1.199
--- php-src/ext/simplexml/simplexml.c:1.198 Sun Mar  5 14:01:13 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Mar  5 15:58:09 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.198 2006/03/05 14:01:13 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.199 2006/03/05 15:58:09 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -409,7 +409,7 @@
int nodendx = 0;
int test = 0;
longcnt;
-   zvaltmp_zv, trim_zv;
+   zvaltmp_zv, trim_zv, value_copy;
 
if (!member) {
/* This happens when the user did: $sxe[] = $value
@@ -477,6 +477,11 @@
case IS_DOUBLE:
case IS_NULL:
case IS_UNICODE:
+   if (value-refcount  1) {
+   value_copy = *value;
+   zval_copy_ctor(value_copy);
+   value = value_copy;
+   }
convert_to_string(value);
break;
case IS_STRING:
@@ -568,6 +573,9 @@
if (pnewnode) {
*pnewnode = newnode;
}
+   if (value  value == value_copy) {
+   zval_dtor(value);
+   }
 }
 /* }}} */
 
@@ -2170,7 +2178,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.198 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.199 $);
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 simplexml.c

2006-03-01 Thread Rob Richards
rrichards   Wed Mar  1 15:36:34 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  nuke tests for libxml2 version - will always be  2.6.0
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.195r2=1.196diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.195 
php-src/ext/simplexml/simplexml.c:1.196
--- php-src/ext/simplexml/simplexml.c:1.195 Mon Feb 27 13:32:25 2006
+++ php-src/ext/simplexml/simplexml.c   Wed Mar  1 15:36:34 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.195 2006/02/27 13:32:25 helly Exp $ */
+/* $Id: simplexml.c,v 1.196 2006/03/01 15:36:34 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1684,11 +1684,7 @@
return;
}
 
-#if LIBXML_VERSION = 20600
docp = xmlReadFile(filename, NULL, options);
-#else
-   docp = xmlParseFile(filename);
-#endif
 
if (! docp) {
RETURN_FALSE;
@@ -1728,11 +1724,7 @@
return;
}
 
-#if LIBXML_VERSION = 20600
docp = xmlReadMemory(data, data_len, NULL, NULL, options);
-#else
-   docp = xmlParseMemory(data, data_len);
-#endif
 
if (! docp) {
RETURN_FALSE;
@@ -1774,11 +1766,9 @@
}
 
php_std_error_handling();
-#if LIBXML_VERSION = 20600
+
docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, 
data_len, NULL, NULL, options);
-#else
-   docp = is_url ? xmlParseFile(data) : xmlParseMemory(data, data_len);
-#endif
+
if (!docp) {
((php_libxml_node_object *)sxe)-document = NULL;
zend_throw_exception(zend_exception_get_default(TSRMLS_C), 
String could not be parsed as XML, 0 TSRMLS_CC);
@@ -2126,7 +2116,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.195 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.196 $);
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 simplexml.c

2006-02-27 Thread Marcus Boerger
helly   Mon Feb 27 11:55:24 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - MFB
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.193r2=1.194diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.193 
php-src/ext/simplexml/simplexml.c:1.194
--- php-src/ext/simplexml/simplexml.c:1.193 Sun Feb 26 16:12:21 2006
+++ php-src/ext/simplexml/simplexml.c   Mon Feb 27 11:55:23 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.193 2006/02/26 16:12:21 helly Exp $ */
+/* $Id: simplexml.c,v 1.194 2006/02/27 11:55:23 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -331,6 +331,10 @@
if (member == tmp_zv) {
zval_dtor(tmp_zv);
}
+   if (Z_TYPE_P(return_value) == IS_NULL) {
+   FREE_ZVAL(return_value);
+   return_value = EG(uninitialized_zval);
+   }
 
return return_value;
 }
@@ -2113,7 +2117,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.193 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.194 $);
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 simplexml.c

2006-02-26 Thread Marcus Boerger
helly   Sun Feb 26 12:00:39 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Unicode support
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.189r2=1.190diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.189 
php-src/ext/simplexml/simplexml.c:1.190
--- php-src/ext/simplexml/simplexml.c:1.189 Sat Feb 25 23:41:06 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Feb 26 12:00:39 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.189 2006/02/25 23:41:06 helly Exp $ */
+/* $Id: simplexml.c,v 1.190 2006/02/26 12:00:39 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -458,6 +458,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 (node) {
if (attribs) {
if (Z_TYPE_P(member) == IS_LONG) {
@@ -527,22 +541,8 @@
}
xmlNewTextChild(mynode-parent, mynode-ns, 
mynode-name, Z_STRVAL_P(value));
}
-   } else {
-   if (attribs) {
-   switch (Z_TYPE_P(value)) {
-   case IS_LONG:
-   case IS_BOOL:
-   case IS_DOUBLE:
-   case IS_NULL:
-   case IS_UNICODE:
-   convert_to_string(value);
-   case IS_STRING:
-   newnode = 
(xmlNodePtr)xmlNewProp(node, name, Z_STRVAL_P(value));
-   break;
-   default:
-   php_error_docref(NULL 
TSRMLS_CC, E_WARNING, It is not yet possible to assign complex types to 
attributes);
-   }
-   }
+   } else if (attribs) {
+   newnode = (xmlNodePtr)xmlNewProp(node, name, 
Z_STRVAL_P(value));
}
}
 
@@ -1273,7 +1273,7 @@
GET_NODE(sxe, node);

namelen = xmlStrlen(node-name);
-   RETURN_STRINGL((char*)node-name, namelen, 1);
+   RETURN_ASCII_STRINGL((char*)node-name, namelen, 1);
 }
 /* }}} */
 
@@ -2067,7 +2067,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.189 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.190 $);
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 simplexml.c /ext/simplexml/tests 028.phpt

2006-02-26 Thread Marcus Boerger
helly   Sun Feb 26 13:37:54 2006 UTC

  Added files: 
/php-src/ext/simplexml/tests028.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Add another write case
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.190r2=1.191diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.190 
php-src/ext/simplexml/simplexml.c:1.191
--- php-src/ext/simplexml/simplexml.c:1.190 Sun Feb 26 12:00:39 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Feb 26 13:37:54 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.190 2006/02/26 12:00:39 helly Exp $ */
+/* $Id: simplexml.c,v 1.191 2006/02/26 13:37:54 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -451,9 +451,14 @@
attr = (xmlAttrPtr)node;
test = sxe-iter.name != NULL;
} else if (sxe-iter.type != SXE_ITER_CHILD) {
+   mynode = node;
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
attr = node ? node-properties : NULL;
test = 0;
+   if (attribs  !node  sxe-iter.type == SXE_ITER_ELEMENT) {
+   node = xmlNewChild(mynode, mynode-ns, sxe-iter.name, 
NULL);
+   attr = node-properties;
+   }
}
 
mynode = node;
@@ -2067,7 +2072,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.190 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.191 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/tests/028.phpt?view=markuprev=1.1
Index: php-src/ext/simplexml/tests/028.phpt
+++ php-src/ext/simplexml/tests/028.phpt
--TEST--
SimpleXML: Adding an elements without text
--SKIPIF--
?php if (!extension_loaded(simplexml)) print skip; ?
--FILE--
?php 
$xml =EOF
people/people
EOF;

function traverse_xml($xml, $pad = '')
{
  $name = $xml-getName();
  echo $pad$name;
  foreach($xml-attributes() as $attr = $value)
  {
echo  $attr=\$value\;
  }
  echo  . trim($xml) . \n;
  foreach($xml-children() as $node)
  {
traverse_xml($node, $pad.'  ');
  }
  echo $pad./$name\n;
}


$people = simplexml_load_string($xml);
traverse_xml($people);
$people-person['name'] = 'John';
traverse_xml($people);

?
===DONE===
--EXPECTF--
people
/people
people
  person name=John
  /person
/people
===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 simplexml.c

2006-02-26 Thread Marcus Boerger
helly   Sun Feb 26 16:12:21 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Missing conversion
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.192r2=1.193diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.192 
php-src/ext/simplexml/simplexml.c:1.193
--- php-src/ext/simplexml/simplexml.c:1.192 Sun Feb 26 15:48:28 2006
+++ php-src/ext/simplexml/simplexml.c   Sun Feb 26 16:12:21 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.192 2006/02/26 15:48:28 helly Exp $ */
+/* $Id: simplexml.c,v 1.193 2006/02/26 16:12:21 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -594,6 +594,7 @@
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
GET_NODE(sxe, node);
+   convert_to_string(member);
name = Z_STRVAL_P(member);
node = sxe_get_element_by_name(sxe, node, name, type TSRMLS_CC);
if (!node) {
@@ -2112,7 +2113,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.192 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.193 $);
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 simplexml.c /ext/simplexml/tests 026.phpt 027.phpt

2006-02-25 Thread Marcus Boerger
helly   Sat Feb 25 23:41:06 2006 UTC

  Added files: 
/php-src/ext/simplexml/tests026.phpt 027.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Added ability to add elements by index if such elements already exist
  - Added SimpleXMLElement::getName() to access the node name
  # This allows to retrieve the name of the root element which is otherwise
  # only available by converting the sxe object into a dom object.
  
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.188r2=1.189diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.188 
php-src/ext/simplexml/simplexml.c:1.189
--- php-src/ext/simplexml/simplexml.c:1.188 Fri Feb 24 15:49:13 2006
+++ php-src/ext/simplexml/simplexml.c   Sat Feb 25 23:41:06 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.188 2006/02/24 15:49:13 helly Exp $ */
+/* $Id: simplexml.c,v 1.189 2006/02/25 23:41:06 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -130,10 +130,10 @@
 }
 /* }}} */
 
-static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, 
xmlNodePtr node) /* {{{ */
+static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, 
xmlNodePtr node, long *cnt) /* {{{ */
 {
long nodendx = 0;
-
+   
if (sxe-iter.type == SXE_ITER_NONE) {
return NULL;
}
@@ -151,6 +151,10 @@
 next_iter:
node = node-next;
}
+   
+   if (cnt) {
+   *cnt = nodendx;
+   }
 
return node;
 }
@@ -303,7 +307,7 @@
if (sxe-iter.type == SXE_ITER_CHILD) {
node = php_sxe_get_first_node(sxe, node 
TSRMLS_CC);
}
-   node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node);
+   node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node, NULL);
if (node) {
_node_as_zval(sxe, node, return_value, 
SXE_ITER_NONE, NULL, sxe-iter.nsprefix TSRMLS_CC);
}
@@ -397,6 +401,7 @@
int is_attr = 0;
int nodendx = 0;
int test = 0;
+   longcnt;
zvaltmp_zv, trim_zv;
 
if (!member) {
@@ -482,7 +487,7 @@
 
if (elements) {
if (Z_TYPE_P(member) == IS_LONG) {
-   newnode = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node);
+   newnode = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node, cnt);
if (newnode) {
++counter;
}
@@ -513,8 +518,15 @@
change_node_zval(newnode, value TSRMLS_CC);
} else if (counter  1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot 
assign to an array of nodes (duplicate subnodes or attr detected));
-   } else if (elements  !node) {
-   xmlNewChild(mynode, mynode-ns, name, 
Z_STRVAL_P(value));   
+   } else if (elements) {
+   if (!node) {
+   xmlNewTextChild(mynode, mynode-ns, name, 
Z_STRVAL_P(value));
+   } else if (Z_TYPE_P(member) == IS_LONG) {
+   if (cnt  Z_LVAL_P(member)) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Cannot add element %s number %ld when only %ld such elements 
exist, mynode-name, Z_LVAL_P(member), cnt);
+   }
+   xmlNewTextChild(mynode-parent, mynode-ns, 
mynode-name, Z_STRVAL_P(value));
+   }
} else {
if (attribs) {
switch (Z_TYPE_P(value)) {
@@ -612,7 +624,7 @@
if (sxe-iter.type == SXE_ITER_CHILD) {
node = php_sxe_get_first_node(sxe, node 
TSRMLS_CC);
}
-   node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node);
+   node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node, NULL);
}
else {
zval tmp_zv;
@@ -1221,7 +1233,7 @@
 }
 /* }}} */
 
-/* {{{ proto object SimpleXMLElement::children()
+/* {{{ proto object SimpleXMLElement::children([string ns])
Finds children of given node */
 SXE_METHOD(children)
 {
@@ -1248,6 +1260,23 @@
 }
 /* }}} */
 
+/* {{{ proto object 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2006-02-24 Thread Marcus Boerger
helly   Fri Feb 24 15:49:13 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Add ability to add new nodes via properties
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.187r2=1.188diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.187 
php-src/ext/simplexml/simplexml.c:1.188
--- php-src/ext/simplexml/simplexml.c:1.187 Tue Feb 21 20:12:42 2006
+++ php-src/ext/simplexml/simplexml.c   Fri Feb 24 15:49:13 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.187 2006/02/21 20:12:42 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.188 2006/02/24 15:49:13 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -390,6 +390,7 @@
char   *name;
xmlNodePtr  node;
xmlNodePtr  newnode = NULL;
+   xmlNodePtr  mynode;
xmlNodePtr  tempnode;
xmlAttrPtr  attr = NULL;
int counter = 0;
@@ -450,6 +451,8 @@
test = 0;
}
 
+   mynode = node;
+
if (node) {
if (attribs) {
if (Z_TYPE_P(member) == IS_LONG) {
@@ -510,6 +513,8 @@
change_node_zval(newnode, value TSRMLS_CC);
} else if (counter  1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot 
assign to an array of nodes (duplicate subnodes or attr detected));
+   } else if (elements  !node) {
+   xmlNewChild(mynode, mynode-ns, name, 
Z_STRVAL_P(value));   
} else {
if (attribs) {
switch (Z_TYPE_P(value)) {
@@ -2032,7 +2037,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.187 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.188 $);
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 simplexml.c

2006-02-06 Thread Antony Dovgal
tony2001Mon Feb  6 10:54:49 2006 UTC

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  MF51: initialize variables
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/simplexml/simplexml.c?r1=1.184r2=1.185diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.184 
php-src/ext/simplexml/simplexml.c:1.185
--- php-src/ext/simplexml/simplexml.c:1.184 Sun Feb  5 23:31:47 2006
+++ php-src/ext/simplexml/simplexml.c   Mon Feb  6 10:54:49 2006
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.184 2006/02/05 23:31:47 helly Exp $ */
+/* $Id: simplexml.c,v 1.185 2006/02/06 10:54:49 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -229,10 +229,10 @@
php_sxe_object *sxe;
char   *name;
xmlNodePtr  node;
-   xmlAttrPtr  attr;
+   xmlAttrPtr  attr = NULL;
zvaltmp_zv;
int nodendx = 0;
-   int test;
+   int test = 0;
 
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
@@ -395,7 +395,7 @@
int counter = 0;
int is_attr = 0;
int nodendx = 0;
-   int test;
+   int test = 0;
zvaltmp_zv, trim_zv;
 
if (!member) {
@@ -560,7 +560,7 @@
xmlNodePtr  node;
xmlAttrPtr  attr = NULL;
int exists = 0;
-   int test;
+   int test = 0;
 
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
@@ -2032,7 +2032,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.184 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.185 $);
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 simplexml.c /ext/spl spl_array.c spl_directory.c spl_iterators.c /ext/unicode unicode_iterators.c pecl/pdo pdo_stmt.c php_pdo_int.h

2006-02-05 Thread Marcus Boerger
helly   Sun Feb  5 23:31:47 2006 UTC

  Modified files:  
/php-src/ext/splspl_iterators.c spl_directory.c spl_array.c 
/php-src/ext/simplexml  simplexml.c 
/pecl/pdo   php_pdo_int.h pdo_stmt.c 
/php-src/ext/unicodeunicode_iterators.c 
  Log:
  - Iterator API was changed
  
  http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.111r2=1.112diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.111 
php-src/ext/spl/spl_iterators.c:1.112
--- php-src/ext/spl/spl_iterators.c:1.111   Mon Jan 23 02:26:15 2006
+++ php-src/ext/spl/spl_iterators.c Sun Feb  5 23:31:47 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_iterators.c,v 1.111 2006/01/23 02:26:15 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.112 2006/02/05 23:31:47 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -278,7 +278,7 @@
object-iterators[object-level].state 
= RS_NEXT;
}
object-iterators = erealloc(object-iterators, 
sizeof(spl_sub_iterator) * (++object-level+1));
-   sub_iter = ce-get_iterator(ce, child 
TSRMLS_CC);
+   sub_iter = ce-get_iterator(ce, child, 0 
TSRMLS_CC);
object-iterators[object-level].iterator = 
sub_iter;
object-iterators[object-level].zobject = 
child;
object-iterators[object-level].ce = ce;
@@ -340,10 +340,16 @@
spl_recursive_it_rewind_ex((spl_recursive_it_object*)iter-data, 
((spl_recursive_it_iterator*)iter)-zobject TSRMLS_CC);
 }
 
-static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry 
*ce, zval *zobject TSRMLS_DC)
+static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry 
*ce, zval *zobject, int by_ref TSRMLS_DC)
 {
-   spl_recursive_it_iterator *iterator = 
emalloc(sizeof(spl_recursive_it_iterator));
-   spl_recursive_it_object   *object   = 
(spl_recursive_it_object*)zend_object_store_get_object(zobject TSRMLS_CC);
+   spl_recursive_it_iterator *iterator;
+   spl_recursive_it_object   *object;
+
+   if (by_ref) {
+   zend_error(E_ERROR, An iterator cannot be used with foreach by 
reference);
+   }
+   iterator = emalloc(sizeof(spl_recursive_it_iterator));
+   object   = 
(spl_recursive_it_object*)zend_object_store_get_object(zobject TSRMLS_CC);
 
zobject-refcount++;
iterator-intern.data = (void*)object;
@@ -430,7 +436,7 @@
intern-nextElement = NULL;
}
ce_iterator = Z_OBJCE_P(iterator); /* respect inheritance, don't use 
spl_ce_RecursiveIterator */
-   intern-iterators[0].iterator = ce_iterator-get_iterator(ce_iterator, 
iterator TSRMLS_CC);
+   intern-iterators[0].iterator = ce_iterator-get_iterator(ce_iterator, 
iterator, 0 TSRMLS_CC);
if (inc_refcount) {
iterator-refcount++;
}
@@ -918,7 +924,7 @@
case DIT_AppendIterator:
spl_instantiate(U_CLASS_ENTRY(spl_ce_ArrayIterator), 
intern-u.append.zarrayit, 1 TSRMLS_CC);

zend_call_method_with_0_params(intern-u.append.zarrayit, 
U_CLASS_ENTRY(spl_ce_ArrayIterator), 
U_CLASS_ENTRY(spl_ce_ArrayIterator)-constructor, __construct, NULL);
-   intern-u.append.iterator = 
U_CLASS_ENTRY(spl_ce_ArrayIterator)-get_iterator(U_CLASS_ENTRY(spl_ce_ArrayIterator),
 intern-u.append.zarrayit TSRMLS_CC);
+   intern-u.append.iterator = 
U_CLASS_ENTRY(spl_ce_ArrayIterator)-get_iterator(U_CLASS_ENTRY(spl_ce_ArrayIterator),
 intern-u.append.zarrayit, 0 TSRMLS_CC);
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return intern;
 #if HAVE_PCRE || HAVE_BUNDLED_PCRE
@@ -954,7 +960,7 @@
intern-inner.zobject = zobject;
intern-inner.ce = dit_type == DIT_IteratorIterator ? ce : 
Z_OBJCE_P(zobject);
intern-inner.object = zend_object_store_get_object(zobject TSRMLS_CC);
-   intern-inner.iterator = 
intern-inner.ce-get_iterator(intern-inner.ce, zobject TSRMLS_CC);
+   intern-inner.iterator = 
intern-inner.ce-get_iterator(intern-inner.ce, zobject, 0 TSRMLS_CC);
 
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return intern;
@@ -2209,7 +2215,7 @@
intern-inner.zobject = *it;
intern-inner.ce = Z_OBJCE_PP(it);
intern-inner.object = zend_object_store_get_object(*it 
TSRMLS_CC);
-   intern-inner.iterator = 
intern-inner.ce-get_iterator(intern-inner.ce, *it TSRMLS_CC);
+   intern-inner.iterator = 
intern-inner.ce-get_iterator(intern-inner.ce, *it, 0 TSRMLS_CC);
spl_dual_it_rewind(intern TSRMLS_CC);
 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 000.phpt 001.phpt 002.phpt 003.phpt 004.phpt 007.phpt 010.phpt 022.phpt 023.phpt 024.phpt /ext/spl/tests sxe_001.phpt

2005-12-07 Thread Dmitry Stogov
dmitry  Wed Dec  7 11:52:13 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests000.phpt 001.phpt 002.phpt 003.phpt 
004.phpt 007.phpt 010.phpt 022.phpt 
023.phpt 024.phpt 
/php-src/ext/spl/tests  sxe_001.phpt 
  Log:
  Unicode support
  
  http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.180r2=1.181ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.180 
php-src/ext/simplexml/simplexml.c:1.181
--- php-src/ext/simplexml/simplexml.c:1.180 Mon Dec  5 21:24:46 2005
+++ php-src/ext/simplexml/simplexml.c   Wed Dec  7 11:52:12 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.180 2005/12/06 02:24:46 sniper Exp $ */
+/* $Id: simplexml.c,v 1.181 2005/12/07 16:52:12 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -746,16 +746,6 @@
 }
 /* }}} */
 
-static inline char * sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, 
int inLine)
-{
-   xmlChar *tmp = xmlNodeListGetString(doc, list, inLine);
-   char*res = estrdup((char*)tmp);
-
-   xmlFree(tmp);
-   
-   return res;
-}
-
 /* {{{ _get_base_node_value()
  */
 static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, 
zval **value, char *prefix TSRMLS_DC)
@@ -768,7 +758,7 @@
if (node-children  node-children-type == XML_TEXT_NODE  
!xmlIsBlankNode(node-children)) {
contents = xmlNodeListGetString(node-doc, node-children, 1);
if (contents) {
-   ZVAL_STRING(*value, contents, 1);
+   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), *value, contents, 1);
xmlFree(contents);
}
} else {
@@ -846,8 +836,11 @@
test = sxe-iter.name  sxe-iter.type == SXE_ITER_ATTRLIST;
while (attr) {
if ((!test || !xmlStrcmp(attr-name, sxe-iter.name)) 
 match_ns(sxe, (xmlNodePtr)attr, sxe-iter.nsprefix)) {
+   xmlChar *tmp;
+
MAKE_STD_ZVAL(value);
-   ZVAL_STRING(value, 
sxe_xmlNodeListGetString((xmlDocPtr) sxe-document-ptr, attr-children, 1), 0);
+   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = 
xmlNodeListGetString((xmlDocPtr) sxe-document-ptr, attr-children, 1), 1);
+   xmlFree(tmp);
namelen = xmlStrlen(attr-name) + 1;
if (!zattr) {
MAKE_STD_ZVAL(zattr);
@@ -864,8 +857,11 @@
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
if (node  sxe-iter.type != SXE_ITER_ATTRLIST) {
if (node-type == XML_ATTRIBUTE_NODE) {
+   xmlChar *tmp;
+
MAKE_STD_ZVAL(value);
-   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, 
sxe_xmlNodeListGetString(node-doc, node-children, 1), 0);
+   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = 
xmlNodeListGetString(node-doc, node-children, 1), 1);
+   xmlFree(tmp);
zend_hash_next_index_insert(rv, value, sizeof(zval *), 
NULL);
node = NULL;
} else {
@@ -877,8 +873,11 @@
SKIP_TEXT(node);
} else {
if (node-type == XML_TEXT_NODE) {
+   xmlChar *tmp;
+
MAKE_STD_ZVAL(value);
-   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, 
sxe_xmlNodeListGetString(node-doc, node, 1), 0);
+   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = 
xmlNodeListGetString(node-doc, node, 1), 1);
+   xmlFree(tmp);
zend_hash_next_index_insert(rv, value, 
sizeof(zval *), NULL);
goto next_iter;
}
@@ -2029,7 +2028,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.180 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.181 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/000.phpt?r1=1.4r2=1.5ty=u
Index: php-src/ext/simplexml/tests/000.phpt
diff -u 

Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 000.phpt 001.phpt 002.phpt 003.phpt 004.phpt 007.phpt 010.phpt 022.phpt 023.phpt 024.phpt /ext/spl/tests sxe_001.phpt

2005-12-07 Thread Jani Taskinen


All these macros around and you still duplicate the stuff?

Instead of doing:

  ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv))...

Why not use the ZVAL_RT_STRING macro? (What is RT supposed to be anyway?)

--Jani


On Wed, 7 Dec 2005, Dmitry Stogov wrote:


dmitry  Wed Dec  7 11:52:13 2005 EDT

 Modified files:
   /php-src/ext/simplexml   simplexml.c
   /php-src/ext/simplexml/tests 000.phpt 001.phpt 002.phpt 003.phpt
004.phpt 007.phpt 010.phpt 022.phpt
023.phpt 024.phpt
   /php-src/ext/spl/tests   sxe_001.phpt
 Log:
 Unicode support




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



RE: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests000.phpt 001.phpt 002.phpt 003.phpt 004.phpt 007.phpt 010.phpt 022.phpt023.phpt 024.phpt /ext/spl/tests sxe_001.phpt

2005-12-07 Thread Dmitry Stogov
Hi Jani,

You are right.
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv))... is equivalent
to ZVAL_RT_STRING.
But simplexml should use not runtime encoding, but XML document encoding
instead.

I hope maintainers will change this.

Thanks. Dmitry.


 -Original Message-
 From: Jani Taskinen [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, December 07, 2005 8:23 PM
 To: Dmitry Stogov
 Cc: php-cvs@lists.php.net
 Subject: Re: [PHP-CVS] cvs: php-src /ext/simplexml 
 simplexml.c /ext/simplexml/tests000.phpt 001.phpt 002.phpt 
 003.phpt 004.phpt 007.phpt 010.phpt 022.phpt023.phpt 024.phpt 
 /ext/spl/tests sxe_001.phpt 
 
 
 
  All these macros around and you still duplicate the stuff?
 
  Instead of doing:
 
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv))...
 
  Why not use the ZVAL_RT_STRING macro? (What is RT 
 supposed to be anyway?)
 
  --Jani
 
 
 On Wed, 7 Dec 2005, Dmitry Stogov wrote:
 
  dmitry  Wed Dec  7 11:52:13 2005 EDT
 
   Modified files:
 /php-src/ext/simplexml   simplexml.c
 /php-src/ext/simplexml/tests 000.phpt 001.phpt 
 002.phpt 003.phpt
  004.phpt 007.phpt 
 010.phpt 022.phpt
  023.phpt 024.phpt
 /php-src/ext/spl/tests   sxe_001.phpt
   Log:
   Unicode support
 
 
 
 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 023.phpt

2005-11-30 Thread Marcus Boerger
helly   Wed Nov 30 03:14:49 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests023.phpt 
  Log:
  - Fix tests
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.178r2=1.179ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.178 
php-src/ext/simplexml/simplexml.c:1.179
--- php-src/ext/simplexml/simplexml.c:1.178 Mon Nov 28 21:46:19 2005
+++ php-src/ext/simplexml/simplexml.c   Wed Nov 30 03:14:48 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.178 2005/11/29 02:46:19 helly Exp $ */
+/* $Id: simplexml.c,v 1.179 2005/11/30 08:14:48 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -865,7 +865,7 @@
if (node  sxe-iter.type != SXE_ITER_ATTRLIST) {
if (node-type == XML_ATTRIBUTE_NODE) {
MAKE_STD_ZVAL(value);
-   ZVAL_STRING(value, sxe_xmlNodeListGetString(node-doc, 
node-children, 1), 0);
+   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, 
sxe_xmlNodeListGetString(node-doc, node-children, 1), 0);
zend_hash_next_index_insert(rv, value, sizeof(zval *), 
NULL);
node = NULL;
} else {
@@ -878,7 +878,7 @@
} else {
if (node-type == XML_TEXT_NODE) {
MAKE_STD_ZVAL(value);
-   ZVAL_STRING(value, 
sxe_xmlNodeListGetString(node-doc, node, 1), 0);
+   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, 
sxe_xmlNodeListGetString(node-doc, node, 1), 0);
zend_hash_next_index_insert(rv, value, 
sizeof(zval *), NULL);
goto next_iter;
}
@@ -2029,7 +2029,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.178 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.179 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/023.phpt?r1=1.4r2=1.5ty=u
Index: php-src/ext/simplexml/tests/023.phpt
diff -u php-src/ext/simplexml/tests/023.phpt:1.4 
php-src/ext/simplexml/tests/023.phpt:1.5
--- php-src/ext/simplexml/tests/023.phpt:1.4Sun Oct 30 09:00:45 2005
+++ php-src/ext/simplexml/tests/023.phptWed Nov 30 03:14:49 2005
@@ -39,7 +39,7 @@
   [u@attributes]=
   array(1) {
 [uattr]=
-string(13) foo bar baz
+string(%d) foo%sbar%sbaz
   }
 }
 object(SimpleXMLElement)#%d (1) {

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



RE: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-11-29 Thread Dmitry Stogov
Hi Marcus,

You broke tests in unicode mode.

Dmitry.

 -Original Message-
 From: Marcus Boerger [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, November 29, 2005 5:46 AM
 To: php-cvs@lists.php.net
 Subject: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c 
 
 
 helly Mon Nov 28 21:46:20 2005 EDT
 
   Modified files:  
 /php-src/ext/simplexmlsimplexml.c 
   Log:
   - Fix some memleaks
   
 http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?
 r1=1.177r2=1.178ty=u
 Index: php-src/ext/simplexml/simplexml.c
 diff -u php-src/ext/simplexml/simplexml.c:1.177 
 php-src/ext/simplexml/simplexml.c:1.178
 --- php-src/ext/simplexml/simplexml.c:1.177   Sun Nov 20 08:03:15 2005
 +++ php-src/ext/simplexml/simplexml.c Mon Nov 28 21:46:19 2005
 @@ -18,7 +18,7 @@

 +-
 -+
  */
  
 -/* $Id: simplexml.c,v 1.177 2005/11/20 13:03:15 helly Exp $ */
 +/* $Id: simplexml.c,v 1.178 2005/11/29 02:46:19 helly Exp $ */
  
  #ifdef HAVE_CONFIG_H
  #include config.h
 @@ -746,10 +746,19 @@
  }
  /* }}} */
  
 +static inline char * sxe_xmlNodeListGetString(xmlDocPtr doc, 
 xmlNodePtr 
 +list, int inLine) {
 + xmlChar *tmp = xmlNodeListGetString(doc, list, inLine);
 + char*res = estrdup((char*)tmp);
 +
 + xmlFree(tmp);
 + 
 + return res;
 +}
 +
  /* {{{ _get_base_node_value()
   */
 -static void
 -_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr 
 node, zval **value, char *prefix TSRMLS_DC)
 +static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr 
 +node, zval **value, char *prefix TSRMLS_DC)
  {
   php_sxe_object *subnode;
   xmlChar*contents;
 @@ -838,7 +847,7 @@
   while (attr) {
   if ((!test || !xmlStrcmp(attr-name, 
 sxe-iter.name))  match_ns(sxe, (xmlNodePtr)attr, 
 sxe-iter.nsprefix)) {
   MAKE_STD_ZVAL(value);
 - ZVAL_STRING(value, 
 xmlNodeListGetString((xmlDocPtr) sxe-document-ptr, 
 attr-children, 1), 1);
 + ZVAL_STRING(value, 
 sxe_xmlNodeListGetString((xmlDocPtr) 
 +sxe-document-ptr, attr-children, 1), 0);
   namelen = xmlStrlen(attr-name) + 1;
   if (!zattr) {
   MAKE_STD_ZVAL(zattr);
 @@ -856,7 +865,7 @@
   if (node  sxe-iter.type != SXE_ITER_ATTRLIST) {
   if (node-type == XML_ATTRIBUTE_NODE) {
   MAKE_STD_ZVAL(value);
 - 
 ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), 
 value, xmlNodeListGetString(node-doc, node-children, 1), 1);
 + ZVAL_STRING(value, 
 sxe_xmlNodeListGetString(node-doc, 
 +node-children, 1), 0);
   zend_hash_next_index_insert(rv, value, 
 sizeof(zval *), NULL);
   node = NULL;
   } else {
 @@ -869,7 +878,7 @@
   } else {
   if (node-type == XML_TEXT_NODE) {
   MAKE_STD_ZVAL(value);
 - 
 ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), 
 value, xmlNodeListGetString(node-doc, node, 1), 1);
 + ZVAL_STRING(value, 
 sxe_xmlNodeListGetString(node-doc, node, 1), 
 +0);
   
 zend_hash_next_index_insert(rv, value, sizeof(zval *), NULL);
   goto next_iter;
   }
 @@ -2020,7 +2029,7 @@
  {
   php_info_print_table_start();
   php_info_print_table_header(2, Simplexml support, enabled);
 - php_info_print_table_row(2, Revision, $Revision: 1.177 $);
 + php_info_print_table_row(2, Revision, $Revision: 1.178 $);
   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 Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-11-28 Thread Marcus Boerger
helly   Mon Nov 28 21:46:20 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Fix some memleaks
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.177r2=1.178ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.177 
php-src/ext/simplexml/simplexml.c:1.178
--- php-src/ext/simplexml/simplexml.c:1.177 Sun Nov 20 08:03:15 2005
+++ php-src/ext/simplexml/simplexml.c   Mon Nov 28 21:46:19 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.177 2005/11/20 13:03:15 helly Exp $ */
+/* $Id: simplexml.c,v 1.178 2005/11/29 02:46:19 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -746,10 +746,19 @@
 }
 /* }}} */
 
+static inline char * sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, 
int inLine)
+{
+   xmlChar *tmp = xmlNodeListGetString(doc, list, inLine);
+   char*res = estrdup((char*)tmp);
+
+   xmlFree(tmp);
+   
+   return res;
+}
+
 /* {{{ _get_base_node_value()
  */
-static void
-_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value, 
char *prefix TSRMLS_DC)
+static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, 
zval **value, char *prefix TSRMLS_DC)
 {
php_sxe_object *subnode;
xmlChar*contents;
@@ -838,7 +847,7 @@
while (attr) {
if ((!test || !xmlStrcmp(attr-name, sxe-iter.name)) 
 match_ns(sxe, (xmlNodePtr)attr, sxe-iter.nsprefix)) {
MAKE_STD_ZVAL(value);
-   ZVAL_STRING(value, 
xmlNodeListGetString((xmlDocPtr) sxe-document-ptr, attr-children, 1), 1);
+   ZVAL_STRING(value, 
sxe_xmlNodeListGetString((xmlDocPtr) sxe-document-ptr, attr-children, 1), 0);
namelen = xmlStrlen(attr-name) + 1;
if (!zattr) {
MAKE_STD_ZVAL(zattr);
@@ -856,7 +865,7 @@
if (node  sxe-iter.type != SXE_ITER_ATTRLIST) {
if (node-type == XML_ATTRIBUTE_NODE) {
MAKE_STD_ZVAL(value);
-   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, 
xmlNodeListGetString(node-doc, node-children, 1), 1);
+   ZVAL_STRING(value, sxe_xmlNodeListGetString(node-doc, 
node-children, 1), 0);
zend_hash_next_index_insert(rv, value, sizeof(zval *), 
NULL);
node = NULL;
} else {
@@ -869,7 +878,7 @@
} else {
if (node-type == XML_TEXT_NODE) {
MAKE_STD_ZVAL(value);
-   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, 
xmlNodeListGetString(node-doc, node, 1), 1);
+   ZVAL_STRING(value, 
sxe_xmlNodeListGetString(node-doc, node, 1), 0);
zend_hash_next_index_insert(rv, value, 
sizeof(zval *), NULL);
goto next_iter;
}
@@ -2020,7 +2029,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.177 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.178 $);
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 simplexml.c

2005-11-20 Thread Marcus Boerger
helly   Sun Nov 20 08:03:19 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Extend SimpleXmlElement::__construct() with two parameters
. int options: pass options to 2.6.0+ parsing functions
. bool data_is_url: whether first parameter is a url rather then xml data
  - Fix parameter parsing
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.176r2=1.177ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.176 
php-src/ext/simplexml/simplexml.c:1.177
--- php-src/ext/simplexml/simplexml.c:1.176 Sat Nov  5 17:41:09 2005
+++ php-src/ext/simplexml/simplexml.c   Sun Nov 20 08:03:15 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.176 2005/11/05 22:41:09 rasmus Exp $ */
+/* $Id: simplexml.c,v 1.177 2005/11/20 13:03:15 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1576,7 +1576,8 @@
int filename_len;
xmlDocPtr   docp;
char   *classname = ;
-   int classname_len = 0, options=0;
+   int classname_len = 0;
+   longoptions = 0;
zend_class_entry *ce= U_CLASS_ENTRY(sxe_class_entry);
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, filename, 
filename_len, classname, classname_len, options) == FAILURE) {
@@ -1619,7 +1620,8 @@
int data_len;
xmlDocPtr   docp;
char   *classname = ;
-   int classname_len = 0, options=0;
+   int classname_len = 0;
+   longoptions = 0;
zend_class_entry *ce= U_CLASS_ENTRY(sxe_class_entry);
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, data, 
data_len, classname, classname_len, options) == FAILURE) {
@@ -1654,7 +1656,7 @@
 /* }}} */
 
 
-/* {{{ proto SimpleXMLElement::__construct()
+/* {{{ proto SimpleXMLElement::__construct(string data [, int options [, bool 
data_is_url]])
SimpleXMLElement constructor */
 SXE_METHOD(__construct)
 {
@@ -1662,15 +1664,21 @@
char   *data;
int data_len;
xmlDocPtr   docp;
+   longoptions = 0;
+   zend_bool   is_url = 0;
 
php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) 
TSRMLS_CC);
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, data, 
data_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lb, data, 
data_len, options, is_url) == FAILURE) {
php_std_error_handling();
return;
}
 
php_std_error_handling();
-   docp = xmlParseMemory(data, data_len);
+#if LIBXML_VERSION = 20600
+   docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, 
data_len, NULL, NULL, options);
+#else
+   docp = is_url ? xmlParseFile(data) : xmlParseMemory(data, data_len);
+#endif
if (!docp) {
((php_libxml_node_object *)sxe)-document = NULL;
zend_throw_exception(zend_exception_get_default(TSRMLS_C), 
String could not be parsed as XML, 0 TSRMLS_CC);
@@ -2012,7 +2020,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.176 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.177 $);
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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-11-20 Thread Nuno Lopes

helly Sun Nov 20 08:03:19 2005 EDT

 Modified files:
   /php-src/ext/simplexml simplexml.c
 Log:
 - Extend SimpleXmlElement::__construct() with two parameters
   . int options: pass options to 2.6.0+ parsing functions
   . bool data_is_url: whether first parameter is a url rather then xml 
data

 - Fix parameter parsing


http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.176r2=1.177ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.176 
php-src/ext/simplexml/simplexml.c:1.177

--- php-src/ext/simplexml/simplexml.c:1.176 Sat Nov  5 17:41:09 2005
+++ php-src/ext/simplexml/simplexml.c Sun Nov 20 08:03:15 2005
@@ -18,7 +18,7 @@
  +--+
*/

-/* $Id: simplexml.c,v 1.176 2005/11/05 22:41:09 rasmus Exp $ */
+/* $Id: simplexml.c,v 1.177 2005/11/20 13:03:15 helly Exp $ */

#ifdef HAVE_CONFIG_H
#include config.h
@@ -1576,7 +1576,8 @@
 int filename_len;
 xmlDocPtr   docp;
 char   *classname = ;
- int classname_len = 0, options=0;
+ int classname_len = 0;
+ longoptions = 0;
 zend_class_entry *ce= U_CLASS_ENTRY(sxe_class_entry);

 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, filename, 
filename_len, classname, classname_len, options) == FAILURE) {

@@ -1619,7 +1620,8 @@
 int data_len;
 xmlDocPtr   docp;
 char   *classname = ;
- int classname_len = 0, options=0;
+ int classname_len = 0;
+ longoptions = 0;
 zend_class_entry *ce= U_CLASS_ENTRY(sxe_class_entry);

 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, data, 
data_len, classname, classname_len, options) == FAILURE) {

@@ -1654,7 +1656,7 @@
/* }}} */


-/* {{{ proto SimpleXMLElement::__construct()
+/* {{{ proto SimpleXMLElement::__construct(string data [, int options [, 
bool data_is_url]])

   SimpleXMLElement constructor */
SXE_METHOD(__construct)
{
@@ -1662,15 +1664,21 @@
 char   *data;
 int data_len;
 xmlDocPtr   docp;
+ longoptions = 0;
+ zend_bool   is_url = 0;

 php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) 
TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, data, 
data_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lb, data, 
data_len, options, is_url) == FAILURE) {

 php_std_error_handling();
 return;
 }

 php_std_error_handling();
- docp = xmlParseMemory(data, data_len);
+#if LIBXML_VERSION = 20600
+ docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, 
data_len, NULL, NULL, options);

+#else
+ docp = is_url ? xmlParseFile(data) : xmlParseMemory(data, data_len);
+#endif



The libxml extension only works with version = 2.6.11 (on both branches), 
so you can remove that #if.


Nuno 


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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-11-05 Thread Rasmus Lerdorf
rasmus  Sat Nov  5 17:41:11 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  MFB - This isn't a DOM thing anymore, just libxml
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.175r2=1.176ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.175 
php-src/ext/simplexml/simplexml.c:1.176
--- php-src/ext/simplexml/simplexml.c:1.175 Tue Nov  1 18:21:28 2005
+++ php-src/ext/simplexml/simplexml.c   Sat Nov  5 17:41:09 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.175 2005/11/01 23:21:28 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.176 2005/11/05 22:41:09 rasmus Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1189,6 +1189,7 @@
}
}
 }
+/* }}} */
 
 /* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive])
Return all namespaces registered with document */
@@ -1865,7 +1866,6 @@
return php_sxe_get_first_node(sxe, node TSRMLS_CC); 
 }
 
-#ifdef HAVE_DOM
 /* {{{ proto simplemxml_element simplexml_import_dom(domNode node [, string 
class_name])
Get a simplexml_element object from dom to allow for processing */
 PHP_FUNCTION(simplexml_import_dom)
@@ -1918,14 +1918,11 @@
}
 }
 /* }}} */
-#endif
 
 function_entry simplexml_functions[] = {
PHP_FE(simplexml_load_file, NULL)
PHP_FE(simplexml_load_string, NULL)
-#ifdef HAVE_DOM
PHP_FE(simplexml_import_dom, NULL)
-#endif
{NULL, NULL, NULL}
 };
 
@@ -2015,7 +2012,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.175 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.176 $);
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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

2005-11-01 Thread Rob Richards

Marcus,

There are a few problems with this approach. A crash will occur if 
adding a default namespace as there is no prefix.
The namespace should probably be the key and prefix the value or default 
namespaces should not be added.


When doing a recursive get, if the namespace is redefined further down 
in the subtree, the redefinition is what ends up in the array rather 
than the closest namespace to the element. Just to be clear this also 
only adds namespaces that are used, not those defined but not used 
(which is probably ok with how they are used in SimpleXML).


When calling getDocNamespaces recursively, if there are any 
redefinitions in the tree, what ends up in the array all depends upon 
the LAST node that get processed by the sxe_add_registered_namespaces 
function.
- probably better to do this one manually and walk the elements in the 
tree checking the nsDef and adding them. Will be faster - one tree 
traversal rather than multiple times (it ascends the entire tree every 
time right now starting from the position of the node passed to 
xmlGetNsList - which is a killer when called recursively).


I dont mind helping with the changes, but not sure exactly how and which 
namespaces you want to pull.


Rob

Marcus Boerger wrote:


helly   Mon Oct 31 14:09:13 2005 EDT

 Added files: 
   /php-src/ext/simplexml/tests	025.phpt 

 Modified files:  
   /php-src/ext/simplexml	simplexml.c 
 Log:

 - Add functions to check for registered/in use namespaces
 
 
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.170r2=1.171ty=u

Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.170 
php-src/ext/simplexml/simplexml.c:1.171
--- php-src/ext/simplexml/simplexml.c:1.170 Sun Oct 30 15:37:07 2005
+++ php-src/ext/simplexml/simplexml.c   Mon Oct 31 14:09:10 2005
@@ -18,7 +18,7 @@
  +--+
*/

 



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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

2005-11-01 Thread Marcus Boerger
Hello Rob,

Tuesday, November 1, 2005, 11:49:22 AM, you wrote:

 Marcus,

 There are a few problems with this approach. A crash will occur if 
 adding a default namespace as there is no prefix.
 The namespace should probably be the key and prefix the value or default 
 namespaces should not be added.

Right, i'll look into that, probbaly adding the with key .

 When doing a recursive get, if the namespace is redefined further down 
 in the subtree, the redefinition is what ends up in the array rather 
 than the closest namespace to the element. Just to be clear this also 
 only adds namespaces that are used, not those defined but not used 
 (which is probably ok with how they are used in SimpleXML).

Easy interface. If that leads to problems do it manually or use dom.
Wans't that our standard answer? :-)

 When calling getDocNamespaces recursively, if there are any 
 redefinitions in the tree, what ends up in the array all depends upon 
 the LAST node that get processed by the sxe_add_registered_namespaces 
 function.
 - probably better to do this one manually and walk the elements in the 
 tree checking the nsDef and adding them. Will be faster - one tree 
 traversal rather than multiple times (it ascends the entire tree every 
 time right now starting from the position of the node passed to 
 xmlGetNsList - which is a killer when called recursively).

Yes it is slow, i thought of the recursive useage only for debugging
purpose.

 I dont mind helping with the changes, but not sure exactly how and which 
 namespaces you want to pull.

great - thanks

marcus

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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

2005-11-01 Thread Rob Richards

Marcus Boerger wrote:

When doing a recursive get, if the namespace is redefined further down 
in the subtree, the redefinition is what ends up in the array rather 
than the closest namespace to the element. Just to be clear this also 
only adds namespaces that are used, not those defined but not used 
(which is probably ok with how they are used in SimpleXML).
   



Easy interface. If that leads to problems do it manually or use dom.
Wans't that our standard answer? :-)
 

Works for me and also answers previous question on redefining default 
namespace.


When calling getDocNamespaces recursively, if there are any 
redefinitions in the tree, what ends up in the array all depends upon 
the LAST node that get processed by the sxe_add_registered_namespaces 
function.
- probably better to do this one manually and walk the elements in the 
tree checking the nsDef and adding them. Will be faster - one tree 
traversal rather than multiple times (it ascends the entire tree every 
time right now starting from the position of the node passed to 
xmlGetNsList - which is a killer when called recursively).
   



Yes it is slow, i thought of the recursive useage only for debugging
purpose.
 

Concern here wasnt as much about speed as you had mentioned it was only 
for debugging, but that a node buried in a document can alter the 
returned namespace array can make debugging a bit harder. I am going to 
change it to search manually which not only will increase speed, but the 
results will be consistent. Since the prefix is going to remain as the 
array key, imo it's probably best if the first encountered namespace in 
document order is used and any dupe prefix skipped.


Rob

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

2005-11-01 Thread Marcus Boerger
helly   Tue Nov  1 06:53:14 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests025.phpt 
  Log:
  - Handle default namespaces
  # Another time it shows xml is far from being simple
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.173r2=1.174ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.173 
php-src/ext/simplexml/simplexml.c:1.174
--- php-src/ext/simplexml/simplexml.c:1.173 Mon Oct 31 15:06:23 2005
+++ php-src/ext/simplexml/simplexml.c   Tue Nov  1 06:53:12 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.173 2005/10/31 20:06:23 helly Exp $ */
+/* $Id: simplexml.c,v 1.174 2005/11/01 11:53:12 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1102,18 +1102,25 @@
 }
 /* }}} */
 
+#define SXE_NS_PREFIX(ns) (ns-prefix ? (char*)ns-prefix : )
+
+static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns)
+{
+   add_assoc_string(return_value, SXE_NS_PREFIX(ns), (char*)ns-href, 1);
+}
+
 static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, zend_bool 
recursive, zval *return_value TSRMLS_DC) /* {{{ */
 {
xmlAttrPtr  attr;
 
if (node-ns) { 
-   add_assoc_string(return_value, (char*)node-ns-prefix, 
(char*)node-ns-href, 1);
+   sxe_add_namespace_name(return_value, node-ns);
}
 
attr = node-properties;
while (attr) {
if (attr-ns) { 
-   add_assoc_string(return_value, (char*)attr-ns-prefix, 
(char*)attr-ns-href, 1);
+   sxe_add_namespace_name(return_value, attr-ns);
}
attr = attr-next;
}
@@ -1152,7 +1159,7 @@
if (node-type == XML_ELEMENT_NODE) {
sxe_add_namespaces(sxe, node, recursive, return_value 
TSRMLS_CC);
} else if (node-type == XML_ATTRIBUTE_NODE  node-ns) {
-   add_assoc_string(return_value, (char*)node-ns-prefix, 
(char*)node-ns-href, 1);
+   sxe_add_namespace_name(return_value, node-ns);
}
 next_iter:
node = node-next;
@@ -1165,7 +1172,7 @@
xmlNsPtr *ns = xmlGetNsList(doc, node);
 
while (ns  ns[0]) {
-   add_assoc_string(return_value, (char*)ns[0]-prefix, 
(char*)ns[0]-href, 1);
+   sxe_add_namespace_name(return_value, ns[0]);
ns++;
}
 
@@ -2003,7 +2010,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.173 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.174 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/025.phpt?r1=1.1r2=1.2ty=u
Index: php-src/ext/simplexml/tests/025.phpt
diff -u php-src/ext/simplexml/tests/025.phpt:1.1 
php-src/ext/simplexml/tests/025.phpt:1.2
--- php-src/ext/simplexml/tests/025.phpt:1.1Mon Oct 31 14:09:13 2005
+++ php-src/ext/simplexml/tests/025.phptTue Nov  1 06:53:14 2005
@@ -23,8 +23,19 @@
 var_dump($sxe-getDocNamespaces());
 var_dump($sxe-getDocNamespaces(true));
 
+$xml =EOF
+?xml version='1.0'?
+html xmlns='http://www.w3.org/1999/xhtml'/
+EOF;
+
+$sxe = simplexml_load_string($xml);
+
+var_dump($sxe-getNamespaces());
+var_dump($sxe-getDocNamespaces());
+
 ?
 ===DONE===
+?php exit(0); ?
 --EXPECTF--
 array(1) {
   [xhtml]=
@@ -54,6 +65,14 @@
   [baz]=
   string(9) foobarbaz
 }
+array(1) {
+  []=
+  string(28) http://www.w3.org/1999/xhtml;
+}
+array(1) {
+  []=
+  string(28) http://www.w3.org/1999/xhtml;
+}
 ===DONE===
 --UEXPECTF--
 array(1) {
@@ -84,4 +103,12 @@
   [ubaz]=
   string(9) foobarbaz
 }
+array(1) {
+  [u]=
+  string(28) http://www.w3.org/1999/xhtml;
+}
+array(1) {
+  [u]=
+  string(28) http://www.w3.org/1999/xhtml;
+}
 ===DONE===

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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

2005-11-01 Thread Marcus Boerger
Hello Rob,

Tuesday, November 1, 2005, 12:59:02 PM, you wrote:

 Marcus Boerger wrote:

When doing a recursive get, if the namespace is redefined further down 
in the subtree, the redefinition is what ends up in the array rather 
than the closest namespace to the element. Just to be clear this also 
only adds namespaces that are used, not those defined but not used 
(which is probably ok with how they are used in SimpleXML).



Easy interface. If that leads to problems do it manually or use dom.
Wans't that our standard answer? :-)
  

 Works for me and also answers previous question on redefining default 
 namespace.

I added code to add default namespaces as  now, looks good, see the test.

When calling getDocNamespaces recursively, if there are any 
redefinitions in the tree, what ends up in the array all depends upon 
the LAST node that get processed by the sxe_add_registered_namespaces 
function.
- probably better to do this one manually and walk the elements in the 
tree checking the nsDef and adding them. Will be faster - one tree 
traversal rather than multiple times (it ascends the entire tree every 
time right now starting from the position of the node passed to 
xmlGetNsList - which is a killer when called recursively).



Yes it is slow, i thought of the recursive useage only for debugging
purpose.
  

 Concern here wasnt as much about speed as you had mentioned it was only 
 for debugging, but that a node buried in a document can alter the 
 returned namespace array can make debugging a bit harder. I am going to 
 change it to search manually which not only will increase speed, but the 
 results will be consistent. Since the prefix is going to remain as the 
 array key, imo it's probably best if the first encountered namespace in 
 document order is used and any dupe prefix skipped.

Ah, skipping dups makes sense in the recursive mode.

marcus

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

2005-11-01 Thread Rob Richards
rrichards   Tue Nov  1 18:21:29 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests025.phpt 
  Log:
  optimize sxe_add_registered_namespaces
  add only first encountered prefixes to namespace arrays
  update test
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.174r2=1.175ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.174 
php-src/ext/simplexml/simplexml.c:1.175
--- php-src/ext/simplexml/simplexml.c:1.174 Tue Nov  1 06:53:12 2005
+++ php-src/ext/simplexml/simplexml.c   Tue Nov  1 18:21:28 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.174 2005/11/01 11:53:12 helly Exp $ */
+/* $Id: simplexml.c,v 1.175 2005/11/01 23:21:28 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1106,7 +1106,10 @@
 
 static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns)
 {
-   add_assoc_string(return_value, SXE_NS_PREFIX(ns), (char*)ns-href, 1);
+   char *prefix = SXE_NS_PREFIX(ns);
+   if (zend_hash_exists(Z_ARRVAL_P(return_value), prefix, strlen(prefix) + 
1) == 0) {
+   add_assoc_string(return_value, prefix, (char*)ns-href, 1);
+   }
 }
 
 static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, zend_bool 
recursive, zval *return_value TSRMLS_DC) /* {{{ */
@@ -1167,25 +1170,27 @@
 }
 /* }}} */
 
-static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlDocPtr doc, 
xmlNodePtr node, zend_bool recursive, zval *return_value TSRMLS_DC) /* {{{ */
+static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr 
node, zend_bool recursive, zval *return_value TSRMLS_DC) /* {{{ */
 {
-   xmlNsPtr *ns = xmlGetNsList(doc, node);
-
-   while (ns  ns[0]) {
-   sxe_add_namespace_name(return_value, ns[0]);
-   ns++;
-   }
+   xmlNsPtr ns;
 
-   if (recursive) {
-   node = node-children;
-   while (node) {
-   sxe_add_registered_namespaces(sxe, doc, node, 
recursive, return_value TSRMLS_CC);
-   node = node-next;
+   if (node-type == XML_ELEMENT_NODE) {
+   ns = node-nsDef;
+   while (ns != NULL) {
+   sxe_add_namespace_name(return_value, ns);
+   ns = ns-next;
+   }
+   if (recursive) {
+   node = node-children;
+   while (node) {
+   sxe_add_registered_namespaces(sxe, node, 
recursive, return_value TSRMLS_CC);
+   node = node-next;
+   }
}
}
 }
 
-/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursve])
+/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive])
Return all namespaces registered with document */
 SXE_METHOD(getDocNamespaces)
 {
@@ -1200,7 +1205,7 @@
 
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
 
-   sxe_add_registered_namespaces(sxe, (xmlDocPtr)sxe-document-ptr, 
xmlDocGetRootElement((xmlDocPtr)sxe-document-ptr), recursive, return_value 
TSRMLS_CC);
+   sxe_add_registered_namespaces(sxe, 
xmlDocGetRootElement((xmlDocPtr)sxe-document-ptr), recursive, return_value 
TSRMLS_CC);
 }
 /* }}} */
 
@@ -2010,7 +2015,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.174 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.175 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/025.phpt?r1=1.3r2=1.4ty=u
Index: php-src/ext/simplexml/tests/025.phpt
diff -u php-src/ext/simplexml/tests/025.phpt:1.3 
php-src/ext/simplexml/tests/025.phpt:1.4
--- php-src/ext/simplexml/tests/025.phpt:1.3Tue Nov  1 06:55:13 2005
+++ php-src/ext/simplexml/tests/025.phptTue Nov  1 18:21:29 2005
@@ -8,7 +8,7 @@
 $xml =EOF
 ?xml version='1.0'?
 xhtml:html xmlns:html='http://www.w3.org/1999/xhtml' 
xmlns:xhtml='http://www.w3.org/TR/REC-html40'
-xhtml:headxhtml:titlebla/xhtml:title/xhtml:head
+xhtml:headxhtml:title 
xmlns:xhtml='http://www.w3.org/TR/REC-html401'bla/xhtml:title/xhtml:head
 xhtml:body html:title=b
 html:h1bla/html:h1
 foo:bar xmlns:foo='foobar' xmlns:baz='foobarbaz'/
@@ -25,7 +25,9 @@
 
 $xml =EOF
 ?xml version='1.0'?
-html xmlns='http://www.w3.org/1999/xhtml'/
+html xmlns='http://www.w3.org/1999/xhtml'
+headtitle xmlns='http://www.w3.org/TR/REC-html40'bla/title/head
+/html
 EOF;
 
 $sxe = simplexml_load_string($xml);

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 025.phpt

2005-10-31 Thread Marcus Boerger
helly   Mon Oct 31 14:09:13 2005 EDT

  Added files: 
/php-src/ext/simplexml/tests025.phpt 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Add functions to check for registered/in use namespaces
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.170r2=1.171ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.170 
php-src/ext/simplexml/simplexml.c:1.171
--- php-src/ext/simplexml/simplexml.c:1.170 Sun Oct 30 15:37:07 2005
+++ php-src/ext/simplexml/simplexml.c   Mon Oct 31 14:09:10 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.170 2005/10/30 20:37:07 helly Exp $ */
+/* $Id: simplexml.c,v 1.171 2005/10/31 19:09:10 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -896,10 +896,7 @@
 }
 /* }}} */
 
-/* {{{ sxe_objects_compare()
- */
-static int
-sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC)
+static int sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC) /* {{{ 
*/
 {
php_sxe_object *sxe1;
php_sxe_object *sxe2;
@@ -1103,6 +1100,99 @@
 }
 /* }}} */
 
+static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, zend_bool 
recursive, zval *return_value TSRMLS_DC) /* {{{ */
+{
+   xmlAttrPtr  attr;
+
+   if (node-ns) { 
+   add_assoc_string(return_value, (char*)node-ns-prefix, 
(char*)node-ns-href, 1);
+   }
+
+   attr = node-properties;
+   while (attr) {
+   if (attr-ns) { 
+   add_assoc_string(return_value, (char*)attr-ns-prefix, 
(char*)attr-ns-href, 1);
+   }
+   attr = attr-next;
+   }
+
+   if (recursive) {
+   node = node-children;
+   while (node) {
+   sxe_add_namespaces(sxe, node, recursive, return_value 
TSRMLS_CC);
+   node = node-next;
+   }
+   }
+} /* }}} */
+
+/* {{{ proto string SimpleXMLElement::getNamespaces([bool recursve])
+   Return all namespaces in use */
+SXE_METHOD(getNamespaces)
+{
+   zend_bool   recursive = 0;
+   php_sxe_object *sxe;
+   xmlNodePtr  node;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |b, recursive) 
== FAILURE) {
+   return;
+   }
+
+   array_init(return_value);
+
+   sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+   GET_NODE(sxe, node);
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+
+   while (node) {
+   SKIP_TEXT(node)
+   if (node-type == XML_ELEMENT_NODE) {
+   sxe_add_namespaces(sxe, node, recursive, return_value 
TSRMLS_CC);
+   } else if (node-ns) {
+   add_assoc_string(return_value, (char*)node-ns-prefix, 
(char*)node-ns-href, 1);
+   }
+next_iter:
+   node = node-next;
+   }
+}
+/* }}} */
+
+static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlDocPtr doc, 
xmlNodePtr node, zend_bool recursive, zval *return_value TSRMLS_DC) /* {{{ */
+{
+   xmlNsPtr *ns = xmlGetNsList(doc, node);
+
+   while (ns  ns[0]) {
+   add_assoc_string(return_value, (char*)ns[0]-prefix, 
(char*)ns[0]-href, 1);
+   ns++;
+   }
+
+   if (recursive) {
+   node = node-children;
+   while (node) {
+   sxe_add_registered_namespaces(sxe, doc, node, 
recursive, return_value TSRMLS_CC);
+   node = node-next;
+   }
+   }
+}
+
+/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursve])
+   Return all namespaces registered with document */
+SXE_METHOD(getDocNamespaces)
+{
+   zend_bool   recursive = 0;
+   php_sxe_object *sxe;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |b, recursive) 
== FAILURE) {
+   return;
+   }
+
+   array_init(return_value);
+
+   sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
+   sxe_add_registered_namespaces(sxe, (xmlDocPtr)sxe-document-ptr, 
xmlDocGetRootElement((xmlDocPtr)sxe-document-ptr), recursive, return_value 
TSRMLS_CC);
+}
+/* }}} */
+
 /* {{{ proto object SimpleXMLElement::children()
Finds children of given node */
 SXE_METHOD(children)
@@ -1204,7 +1294,7 @@
int rv;
 
sxe = php_sxe_fetch_object(readobj TSRMLS_CC);
-
+   
if (type == IS_BOOL) {
node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC);
INIT_PZVAL(writeobj);
@@ -1830,9 +1920,11 @@
SXE_ME(__construct,NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) /* 
must be called */
SXE_ME(asXML,  NULL, ZEND_ACC_PUBLIC)
SXE_ME(xpath,  NULL, ZEND_ACC_PUBLIC)
-   SXE_ME(registerXPathNamespace,  NULL, ZEND_ACC_PUBLIC)
+   

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-10-31 Thread Rob Richards
rrichards   Mon Oct 31 14:51:44 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  check node type before accessing ns - prevent corruption under compact mode
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.171r2=1.172ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.171 
php-src/ext/simplexml/simplexml.c:1.172
--- php-src/ext/simplexml/simplexml.c:1.171 Mon Oct 31 14:09:10 2005
+++ php-src/ext/simplexml/simplexml.c   Mon Oct 31 14:51:40 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.171 2005/10/31 19:09:10 helly Exp $ */
+/* $Id: simplexml.c,v 1.172 2005/10/31 19:51:40 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1119,7 +1119,9 @@
if (recursive) {
node = node-children;
while (node) {
-   sxe_add_namespaces(sxe, node, recursive, return_value 
TSRMLS_CC);
+   if (node-type == XML_ELEMENT_NODE) {
+   sxe_add_namespaces(sxe, node, recursive, 
return_value TSRMLS_CC);
+   }
node = node-next;
}
}
@@ -1147,7 +1149,7 @@
SKIP_TEXT(node)
if (node-type == XML_ELEMENT_NODE) {
sxe_add_namespaces(sxe, node, recursive, return_value 
TSRMLS_CC);
-   } else if (node-ns) {
+   } else if (node-type == XML_ATTRIBUTE_NODE  node-ns) {
add_assoc_string(return_value, (char*)node-ns-prefix, 
(char*)node-ns-href, 1);
}
 next_iter:
@@ -1977,7 +1979,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.171 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.172 $);
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 simplexml.c /ext/simplexml/tests 000.phpt

2005-10-31 Thread Marcus Boerger
helly   Mon Oct 31 15:06:29 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests000.phpt 
  Log:
  - Implement count interface
  
  http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.172r2=1.173ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.172 
php-src/ext/simplexml/simplexml.c:1.173
--- php-src/ext/simplexml/simplexml.c:1.172 Mon Oct 31 14:51:40 2005
+++ php-src/ext/simplexml/simplexml.c   Mon Oct 31 15:06:23 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.172 2005/10/31 19:51:40 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.173 2005/10/31 20:06:23 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -53,6 +53,8 @@
 
 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);
+static xmlNodePtr php_sxe_reset_iterator(php_sxe_object *sxe, int use_data 
TSRMLS_DC);
+static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, 
int use_data TSRMLS_DC);
 
 /* {{{ _node_as_zval()
  */
@@ -103,7 +105,7 @@
xmlNodePtr retnode = NULL;
 
if (sxe  sxe-iter.type != SXE_ITER_NONE) {
-   php_sxe_reset_iterator(sxe TSRMLS_CC);
+   php_sxe_reset_iterator(sxe, 1 TSRMLS_CC);
if (sxe-iter.data) {
intern = (php_sxe_object 
*)zend_object_store_get_object(sxe-iter.data TSRMLS_CC);
GET_NODE(intern, retnode)
@@ -1332,6 +1334,26 @@
 }
 /* }}} */
 
+static int sxe_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
+{
+   php_sxe_object  *sxe;
+   xmlNodePtr   node;
+
+   *count = 0;
+   sxe = php_sxe_fetch_object(object TSRMLS_CC);
+   node = php_sxe_reset_iterator(sxe, 0 TSRMLS_CC);
+   
+   while (node)
+   {
+   (*count)++;
+   node = php_sxe_iterator_fetch(sxe, node-next, 0 TSRMLS_CC);
+   }
+
+
+   return SUCCESS;
+}
+/* }}} */
+
 static zval *sxe_get_value(zval *z TSRMLS_DC)
 {
zval *retval;
@@ -1369,7 +1391,7 @@
NULL, /* zend_get_std_object_handlers()-get_class_name,*/
sxe_objects_compare,
sxe_object_cast,
-   NULL
+   sxe_count_elements
 };
 
 static zend_object_handlers sxe_ze1_object_handlers = {
@@ -1393,7 +1415,7 @@
NULL, /* zend_get_std_object_handlers()-get_class_name,*/
sxe_objects_compare,
sxe_object_cast,
-   NULL
+   sxe_count_elements
 };
 
 static zend_object_value sxe_object_ze1_clone(zval *zobject TSRMLS_DC)
@@ -1664,7 +1686,7 @@
php_sxe_iterator_rewind,
 };
 
-static void php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node 
TSRMLS_DC)
+static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, 
int use_data TSRMLS_DC)
 {
char *prefix = sxe-iter.nsprefix;
int test_elem = sxe-iter.type == SXE_ITER_ELEMENT   sxe-iter.name;
@@ -1685,13 +1707,15 @@
node = node-next;
}
 
-   if (node) {
+   if (node  use_data) {
ALLOC_INIT_ZVAL(sxe-iter.data);
_node_as_zval(sxe, node, sxe-iter.data, SXE_ITER_NONE, NULL, 
sxe-iter.nsprefix TSRMLS_CC);
}
+
+   return node;
 }
 
-ZEND_API void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC)
+static xmlNodePtr php_sxe_reset_iterator(php_sxe_object *sxe, int use_data 
TSRMLS_DC)
 {
xmlNodePtr node;
 
@@ -1712,8 +1736,9 @@
case SXE_ITER_ATTRLIST:
node = (xmlNodePtr) node-properties;
}
-   php_sxe_iterator_fetch(sxe, node TSRMLS_CC);
+   return php_sxe_iterator_fetch(sxe, node, use_data TSRMLS_CC);
}
+   return NULL;
 }
 
 zend_object_iterator *php_sxe_get_iterator(zend_class_entry *ce, zval *object 
TSRMLS_DC)
@@ -1798,7 +1823,7 @@
}
 
if (node) {
-   php_sxe_iterator_fetch(sxe, node-next TSRMLS_CC);
+   php_sxe_iterator_fetch(sxe, node-next, 1 TSRMLS_CC);
}
 }
 
@@ -1815,10 +1840,9 @@
php_sxe_iterator *iterator = (php_sxe_iterator *)iter;
sxe = iterator-sxe;
 
-   php_sxe_reset_iterator(sxe TSRMLS_CC);
+   php_sxe_reset_iterator(sxe, 1 TSRMLS_CC);
 }
 
-
 void *simplexml_export_node(zval *object TSRMLS_DC)
 {
php_sxe_object *sxe;
@@ -1979,7 +2003,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.172 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.173 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 000.phpt

2005-10-30 Thread Marcus Boerger
helly   Sun Oct 30 15:37:30 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests000.phpt 
  Log:
  - Bugfix #35028 XML object fails FALSE test
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.169r2=1.170ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.169 
php-src/ext/simplexml/simplexml.c:1.170
--- php-src/ext/simplexml/simplexml.c:1.169 Sat Oct 29 20:38:39 2005
+++ php-src/ext/simplexml/simplexml.c   Sun Oct 30 15:37:07 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.169 2005/10/30 00:38:39 helly Exp $ */
+/* $Id: simplexml.c,v 1.170 2005/10/30 20:37:07 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1205,6 +1205,13 @@
 
sxe = php_sxe_fetch_object(readobj TSRMLS_CC);
 
+   if (type == IS_BOOL) {
+   node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC);
+   INIT_PZVAL(writeobj);
+   ZVAL_BOOL(writeobj, node != NULL || 
zend_hash_num_elements(sxe_properties_get(readobj TSRMLS_CC))  0);
+   return SUCCESS;
+   }
+
if (sxe-iter.type != SXE_ITER_NONE) {
node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC);
if (node) {
@@ -1878,7 +1885,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.169 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.170 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/000.phpt?r1=1.2r2=1.3ty=u
Index: php-src/ext/simplexml/tests/000.phpt
diff -u php-src/ext/simplexml/tests/000.phpt:1.2 
php-src/ext/simplexml/tests/000.phpt:1.3
--- php-src/ext/simplexml/tests/000.phpt:1.2Sun Oct 30 09:00:45 2005
+++ php-src/ext/simplexml/tests/000.phptSun Oct 30 15:37:22 2005
@@ -12,6 +12,7 @@
global $sxe;
echo ===$what\n;
eval(var_dump(isset(\$$what)););
+   eval(var_dump((bool)\$$what););
eval(var_dump(\$$what););
 }
 
@@ -20,7 +21,7 @@
 test('sxe-elem1[0]');
 test('sxe-elem1[0]-elem2');
 test('sxe-elem1[0]-elem2-bla');
-test('sxe-elem1[0][attr1]');
+if (!ini_get(unicode_semantics)) test('sxe-elem1[0][attr1]');
 test('sxe-elem1[0]-attr1');
 test('sxe-elem1[1]');
 test('sxe-elem1[2]');
@@ -38,6 +39,7 @@
 --EXPECTF--
 ===sxe
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (3) {
   [@attributes]=
   array(1) {
@@ -71,6 +73,7 @@
 }
 ===sxe-elem1
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (3) {
   [@attributes]=
   array(2) {
@@ -104,6 +107,7 @@
 }
 ===sxe-elem1[0]
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (3) {
   [@attributes]=
   array(2) {
@@ -137,6 +141,7 @@
 }
 ===sxe-elem1[0]-elem2
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (2) {
   [@attributes]=
   array(2) {
@@ -157,20 +162,24 @@
 }
 ===sxe-elem1[0]-elem2-bla
 bool(false)
+bool(false)
 object(SimpleXMLElement)#%d (0) {
 }
 ===sxe-elem1[0][attr1]
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (1) {
   [0]=
   string(5) first
 }
 ===sxe-elem1[0]-attr1
 bool(false)
+bool(false)
 object(SimpleXMLElement)#%d (0) {
 }
 ===sxe-elem1[1]
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (1) {
   [@attributes]=
   array(2) {
@@ -182,9 +191,11 @@
 }
 ===sxe-elem1[2]
 bool(false)
+bool(false)
 NULL
 ===sxe-elem11
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (1) {
   [elem111]=
   object(SimpleXMLElement)#%d (1) {
@@ -195,6 +206,7 @@
 }
 ===sxe-elem11-elem111
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (1) {
   [elem]=
   object(SimpleXMLElement)#%d (0) {
@@ -202,25 +214,31 @@
 }
 ===sxe-elem11-elem111-elem
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (0) {
 }
 ===sxe-elem22
 bool(false)
+bool(false)
 object(SimpleXMLElement)#%d (0) {
 }
 ===sxe-elem22-elem222
 bool(false)
+bool(false)
 NULL
 ===sxe-elem22-attr22
 bool(false)
+bool(false)
 NULL
 ===sxe-elem22[attr22]
 bool(false)
+bool(false)
 NULL
 ===DONE===
 --UEXPECTF--
 ===sxe
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (3) {
   [u@attributes]=
   array(1) {
@@ -254,6 +272,7 @@
 }
 ===sxe-elem1
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (3) {
   [u@attributes]=
   array(2) {
@@ -287,6 +306,7 @@
 }
 ===sxe-elem1[0]
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (3) {
   [u@attributes]=
   array(2) {
@@ -320,6 +340,7 @@
 }
 ===sxe-elem1[0]-elem2
 bool(true)
+bool(true)
 object(SimpleXMLElement)#%d (2) {
   [u@attributes]=
   array(2) {
@@ -340,20 +361,17 @@
 }
 ===sxe-elem1[0]-elem2-bla
 bool(false)
-object(SimpleXMLElement)#%d (0) {
-}
-===sxe-elem1[0][attr1]
 bool(false)
-object(SimpleXMLElement)#%d (1) {
-  [0]=
-  unicode(5) first
+object(SimpleXMLElement)#%d (0) {
 }

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 000.phpt 000.xml 001.phpt 002.phpt 003.phpt 004.phpt 005.phpt 006.phpt 007.phpt 008.phpt 009.phpt 010.phpt 011.phpt 012.phpt 013

2005-10-29 Thread Marcus Boerger
helly   Sat Oct 29 12:12:57 2005 EDT

  Added files: 
/php-src/ext/simplexml/tests000.phpt 000.xml 

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests001.phpt 002.phpt 003.phpt 004.phpt 
005.phpt 006.phpt 007.phpt 008.phpt 
009.phpt 010.phpt 011.phpt 012.phpt 
013.phpt 019.phpt 020.phpt 021.phpt 
022.phpt 023.phpt bug27010.phpt 
profile11.phpt 
simplexml_import_dom.phpt sxe.dtd 
  Log:
  - Change var_dump to include all that is reachable, incl. @attributes
  - Adapt tests and add new one
  
  http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.164r2=1.165ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.164 
php-src/ext/simplexml/simplexml.c:1.165
--- php-src/ext/simplexml/simplexml.c:1.164 Sun Oct 23 19:41:18 2005
+++ php-src/ext/simplexml/simplexml.c   Sat Oct 29 12:12:55 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.164 2005/10/23 23:41:18 helly Exp $ */
+/* $Id: simplexml.c,v 1.165 2005/10/29 16:12:55 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -38,6 +38,8 @@
 #include ext/spl/spl_sxe.h
 #endif
 
+#define SXE_ELEMENT_BY_NAME 0
+
 zend_class_entry *sxe_class_entry = NULL;
 
 ZEND_API zend_class_entry *sxe_get_element_class_entry(TSRMLS_D)
@@ -112,10 +114,7 @@
}
 }
 
-/* {{{ match_ns()
- */
-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) /* {{{ */
 {
if (name == NULL  (node-ns == NULL || node-ns-prefix == NULL)) {
return 1;
@@ -129,9 +128,8 @@
 }
 /* }}} */
 
-/* {{{ sxe_get_element_node()
- */
-static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, 
xmlNodePtr 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) {
@@ -156,6 +154,71 @@
 }
 /* }}} */
 
+#if SXE_ELEMENT_BY_NAME
+static xmlNodePtr sxe_find_element_by_name(php_sxe_object *sxe, xmlNodePtr 
node, char *name TSRMLS_DC) /* {{{ */
+{
+   while (node) {
+   SKIP_TEXT(node)
+   if (node-type == XML_ELEMENT_NODE  match_ns(sxe, node, 
sxe-iter.nsprefix)) {
+   if (!xmlStrcmp(node-name, name)) {
+   return node;
+   }
+   }
+next_iter:
+   node = node-next;
+   }
+   return NULL;
+} /* }}} */
+
+static xmlNodePtr sxe_get_element_by_name(php_sxe_object *sxe, xmlNodePtr 
node, char **name, int *type TSRMLS_DC) /* {{{ */
+{
+   int orgtype;
+   xmlNodePtr  orgnode = node;
+   xmlNodePtr  retnode = NULL;
+
+   if (sxe-iter.type != SXE_ITER_ATTRLIST)
+   {
+   orgtype = sxe-iter.type;
+   if (sxe-iter.type == SXE_ITER_NONE) {
+   sxe-iter.type = SXE_ITER_CHILD;
+   }
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+   sxe-iter.type = orgtype;
+   }
+
+   if (sxe-iter.type == SXE_ITER_ELEMENT) {
+   orgnode = sxe_find_element_by_name(sxe, node, sxe-iter.name 
TSRMLS_CC);
+   node = orgnode-children;
+   }
+
+   while (node) {
+   SKIP_TEXT(node)
+   if (node-type == XML_ELEMENT_NODE  match_ns(sxe, node, 
sxe-iter.nsprefix)) {
+   if (!xmlStrcmp(node-name, *name)) {
+   if (1||retnode)
+   {
+   *type = SXE_ITER_ELEMENT;
+   return orgnode;
+   }
+   retnode = node;
+   }
+   }
+next_iter:
+   node = node-next;
+   }
+
+   if (retnode)
+   {
+   *type = SXE_ITER_NONE;
+   *name = NULL;
+   return retnode;
+   }
+
+   return NULL;
+}
+/* }}} */
+#endif /* SXE_ELEMENT_BY_NAME */
+
 /* {{{ 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)
@@ -166,7 +229,7 @@
xmlNodePtr  node;
xmlAttrPtr  attr;
zvaltmp_zv;
-   int nodendx = 0;
+   int nodendx = 0;
 
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
@@ -175,6 +238,7 @@
attribs = 0;
 

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-10-29 Thread Marcus Boerger
helly   Sat Oct 29 17:16:19 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Fix attribute handling when using xpath expressions that lead to attributes
  http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.165r2=1.166ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.165 
php-src/ext/simplexml/simplexml.c:1.166
--- php-src/ext/simplexml/simplexml.c:1.165 Sat Oct 29 12:12:55 2005
+++ php-src/ext/simplexml/simplexml.c   Sat Oct 29 17:16:17 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.165 2005/10/29 16:12:55 helly Exp $ */
+/* $Id: simplexml.c,v 1.166 2005/10/29 21:16:17 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -230,6 +230,7 @@
xmlAttrPtr  attr;
zvaltmp_zv;
int nodendx = 0;
+   int test;
 
sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
@@ -257,16 +258,21 @@
if (sxe-iter.type == SXE_ITER_ATTRLIST) {
attribs = 1;
elements = 0;   
-   } else if (sxe-iter.type != SXE_ITER_CHILD  sxe-iter.type != 
SXE_ITER_ATTRLIST) {
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+   attr = (xmlAttrPtr)node;
+   test = sxe-iter.name != NULL;
+   } else if (sxe-iter.type != SXE_ITER_CHILD) {
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+   attr = node ? node-properties : NULL;
+   test = 0;
}
+
if (node) {
if (attribs) {
if (Z_TYPE_P(member) != IS_LONG || sxe-iter.type == 
SXE_ITER_ATTRLIST) {
-   attr = node-properties;
if (Z_TYPE_P(member) == IS_LONG) {
while (attr  nodendx = 
Z_LVAL_P(member)) {
-   if (match_ns(sxe, (xmlNodePtr) 
attr, sxe-iter.nsprefix)) {
+   if ((!test || 
!xmlStrcmp(attr-name, sxe-iter.name))  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, 
sxe-iter.nsprefix TSRMLS_CC);
break;
@@ -277,7 +283,7 @@
}
} else {
while (attr) {
-   if (!xmlStrcmp(attr-name, 
name)  match_ns(sxe, (xmlNodePtr) attr, sxe-iter.nsprefix)) {
+   if ((!test || 
!xmlStrcmp(attr-name, sxe-iter.name))  !xmlStrcmp(attr-name, name)  
match_ns(sxe, (xmlNodePtr) attr, sxe-iter.nsprefix)) {
_node_as_zval(sxe, 
(xmlNodePtr) attr, return_value, SXE_ITER_NONE, NULL, sxe-iter.nsprefix 
TSRMLS_CC);
break;
}
@@ -388,6 +394,7 @@
int counter = 0;
int is_attr = 0;
int nodendx = 0;
+   int test;
zvaltmp_zv, trim_zv;
 
if (!member) {
@@ -430,16 +437,23 @@
 
GET_NODE(sxe, node);
 
-   if (sxe-iter.type != SXE_ITER_ATTRLIST) {
+   if (sxe-iter.type == SXE_ITER_ATTRLIST) {
+   attribs = 1;
+   elements = 0;   
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+   attr = (xmlAttrPtr)node;
+   test = sxe-iter.name != NULL;
+   } else if (sxe-iter.type != SXE_ITER_CHILD) {
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+   attr = node ? node-properties : NULL;
+   test = 0;
}
 
if (node) {
if (attribs) {
-   attr = node-properties;
if (Z_TYPE_P(member) == IS_LONG) {
while (attr  nodendx = Z_LVAL_P(member)) {
-   if (match_ns(sxe, (xmlNodePtr) attr, 
sxe-iter.nsprefix)) {
+   if ((!test || !xmlStrcmp(attr-name, 
sxe-iter.name))  match_ns(sxe, (xmlNodePtr) attr, sxe-iter.nsprefix)) {
if (nodendx == 
Z_LVAL_P(member)) {
is_attr = 1;
++counter;
@@ -451,7 +465,7 @@
}
} else {

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-10-29 Thread Marcus Boerger
helly   Sat Oct 29 20:38:42 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Protect against some edge case that is currently imossible, but will be
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.168r2=1.169ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.168 
php-src/ext/simplexml/simplexml.c:1.169
--- php-src/ext/simplexml/simplexml.c:1.168 Sat Oct 29 20:35:55 2005
+++ php-src/ext/simplexml/simplexml.c   Sat Oct 29 20:38:39 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.168 2005/10/30 00:35:55 helly Exp $ */
+/* $Id: simplexml.c,v 1.169 2005/10/30 00:38:39 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1568,7 +1568,7 @@
 static void php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node 
TSRMLS_DC)
 {
char *prefix = sxe-iter.nsprefix;
-   int test_elem = sxe-iter.type == SXE_ITER_ELEMENT;
+   int test_elem = sxe-iter.type == SXE_ITER_ELEMENT   sxe-iter.name;
int test_attr = sxe-iter.type == SXE_ITER_ATTRLIST  sxe-iter.name;
 
while (node) {
@@ -1878,7 +1878,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.168 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.169 $);
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 simplexml.c /ext/simplexml/tests 023.phpt

2005-10-23 Thread Marcus Boerger
helly   Sun Oct 23 19:41:20 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/simplexml/tests023.phpt 
  Log:
  - Fix issue with entities in attributes
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.163r2=1.164ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.163 
php-src/ext/simplexml/simplexml.c:1.164
--- php-src/ext/simplexml/simplexml.c:1.163 Thu Oct  6 02:27:27 2005
+++ php-src/ext/simplexml/simplexml.c   Sun Oct 23 19:41:18 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.163 2005/10/06 06:27:27 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.164 2005/10/23 23:41:18 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -701,7 +701,14 @@
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
if (node) {
-   node = node-children;
+   if (node-type == XML_ATTRIBUTE_NODE) {
+   MAKE_STD_ZVAL(value);
+   
ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, 
xmlNodeListGetString(node-doc, node-children, 1), 1);
+   zend_hash_next_index_insert(rv, value, sizeof(zval *), 
NULL);
+   node = NULL;
+   } else {
+   node = node-children;
+   }
 
while (node) {
if (node-children != NULL || node-prev != NULL || 
node-next != NULL) {
@@ -1757,7 +1764,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.163 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.164 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/simplexml/tests/023.phpt?r1=1.1r2=1.2ty=u
Index: php-src/ext/simplexml/tests/023.phpt
diff -u php-src/ext/simplexml/tests/023.phpt:1.1 
php-src/ext/simplexml/tests/023.phpt:1.2
--- php-src/ext/simplexml/tests/023.phpt:1.1Sun Oct 23 19:25:46 2005
+++ php-src/ext/simplexml/tests/023.phptSun Oct 23 19:41:20 2005
@@ -22,11 +22,9 @@
 ?
 ===DONE===
 --EXPECTF--
-object(SimpleXMLElement)#1 (1) {
-  [attr]=
-  string(%d) foo%sbar%sbaz
+object(SimpleXMLElement)#%d (0) {
 }
-object(SimpleXMLElement)#2 (1) {
+object(SimpleXMLElement)#%d (1) {
   [0]=
   string(%d) foo%sbar%sbaz
 }

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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-10-06 Thread Dmitry Stogov
dmitry  Thu Oct  6 02:27:28 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fixed compilation error
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.162r2=1.163ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.162 
php-src/ext/simplexml/simplexml.c:1.163
--- php-src/ext/simplexml/simplexml.c:1.162 Wed Oct  5 15:12:42 2005
+++ php-src/ext/simplexml/simplexml.c   Thu Oct  6 02:27:27 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.162 2005/10/05 19:12:42 helly Exp $ */
+/* $Id: simplexml.c,v 1.163 2005/10/06 06:27:27 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1083,7 +1083,7 @@
 
MAKE_STD_ZVAL(retval);
 
-   if (sxe_object_cast(z, retval, IS_STRING, 0 TSRMLS_CC)==FAILURE) {
+   if (sxe_object_cast(z, retval, IS_STRING TSRMLS_CC)==FAILURE) {
zend_error(E_ERROR, Unable to cast node to string);
/* FIXME: Should not be fatal */
}
@@ -1757,7 +1757,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.162 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.163 $);
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 simplexml.c /ext/spl spl_directory.c spl_iterators.c /ext/tidy tidy.c

2005-10-05 Thread Marcus Boerger
helly   Wed Oct  5 15:12:44 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/splspl_directory.c spl_iterators.c 
/php-src/ext/tidy   tidy.c 
  Log:
  - Update cast_object handlers
  http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.161r2=1.162ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.161 
php-src/ext/simplexml/simplexml.c:1.162
--- php-src/ext/simplexml/simplexml.c:1.161 Mon Oct  3 12:04:50 2005
+++ php-src/ext/simplexml/simplexml.c   Wed Oct  5 15:12:42 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.161 2005/10/03 16:04:50 helly Exp $ */
+/* $Id: simplexml.c,v 1.162 2005/10/05 19:12:42 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1040,20 +1040,15 @@
 /* {{{ sxe_object_cast()
  */
 static int
-sxe_object_cast(zval *readobj, zval *writeobj, int type, int should_free 
TSRMLS_DC)
+sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
 {
php_sxe_object *sxe;
char   *contents = NULL;
xmlNodePtr  node;
-   zval free_obj;
int rv;
 
sxe = php_sxe_fetch_object(readobj TSRMLS_CC);
 
-   if (should_free) {
-   free_obj = *writeobj;
-   }
-
if (sxe-iter.type != SXE_ITER_NONE) {
node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC);
if (node) {
@@ -1078,9 +1073,6 @@
if (contents) {
xmlFree(contents);
}
-   if (should_free) {
-   zval_dtor(free_obj);
-   }
return rv;
 }
 /* }}} */
@@ -1765,7 +1757,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.161 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.162 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.48r2=1.49ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.48 
php-src/ext/spl/spl_directory.c:1.49
--- php-src/ext/spl/spl_directory.c:1.48Thu Sep 15 10:07:38 2005
+++ php-src/ext/spl/spl_directory.c Wed Oct  5 15:12:43 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_directory.c,v 1.48 2005/09/15 14:07:38 helly Exp $ */
+/* $Id: spl_directory.c,v 1.49 2005/10/05 19:12:43 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -793,19 +793,12 @@
 /* }}} */
 
 /* {{{ spl_ce_dir_cast */
-static int spl_ce_dir_cast(zval *readobj, zval *writeobj, int type, int 
should_free TSRMLS_DC)
+static int spl_ce_dir_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
 {
-   zval free_obj;
spl_ce_dir_object   *dir_object = 
(spl_ce_dir_object*)zend_object_store_get_object(readobj TSRMLS_CC);
 
if (type ==IS_STRING  *dir_object-entry.d_name) {
-   if (should_free) {
-   free_obj = *writeobj;
-   }
ZVAL_STRING(writeobj, dir_object-entry.d_name, 1);
-   if (should_free) {
-   zval_dtor(free_obj);
-   }
return SUCCESS;
}
return FAILURE;
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.87r2=1.88ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.87 
php-src/ext/spl/spl_iterators.c:1.88
--- php-src/ext/spl/spl_iterators.c:1.87Mon Oct  3 06:08:56 2005
+++ php-src/ext/spl/spl_iterators.c Wed Oct  5 15:12:43 2005
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: spl_iterators.c,v 1.87 2005/10/03 10:08:56 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.88 2005/10/05 19:12:43 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include config.h
@@ -1522,46 +1522,19 @@
zval_ptr_dtor(retval); 
}
if (intern-u.caching.flags  CIT_CALL_TOSTRING) {
-   if (Z_TYPE_P(intern-current.data) == IS_OBJECT) {
-   zval expr_copy;
-   if 
(intern-current.data-value.obj.handlers-cast_object 
-   
intern-current.data-value.obj.handlers-cast_object(intern-current.data, 
expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS)
-   {
-   ALLOC_ZVAL(intern-u.caching.zstr);
-   *intern-u.caching.zstr = expr_copy;
-   INIT_PZVAL(intern-u.caching.zstr);
-   zval_copy_ctor(intern-u.caching.zstr);
-

[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-08-31 Thread Rob Richards
rrichards   Wed Aug 31 13:00:25 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  make sxe_properties_get respect namespace scope
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.158r2=1.159ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.158 
php-src/ext/simplexml/simplexml.c:1.159
--- php-src/ext/simplexml/simplexml.c:1.158 Tue Aug 23 05:33:44 2005
+++ php-src/ext/simplexml/simplexml.c   Wed Aug 31 13:00:22 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.158 2005/08/23 09:33:44 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.159 2005/08/31 17:00:22 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -642,7 +642,7 @@
 /* {{{ _get_base_node_value()
  */
 static void
-_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value 
TSRMLS_DC)
+_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value, 
char *prefix TSRMLS_DC)
 {
php_sxe_object *subnode;
xmlChar*contents;
@@ -659,6 +659,9 @@
subnode = php_sxe_object_new(sxe_ref-zo.ce TSRMLS_CC);
subnode-document = sxe_ref-document;
subnode-document-refcount++;
+   if (prefix) {
+   subnode-iter.nsprefix = xmlStrdup(prefix);
+   }
php_libxml_increment_node_ptr((php_libxml_node_object 
*)subnode, node, NULL TSRMLS_CC);
 
(*value)-type = IS_OBJECT;
@@ -712,6 +715,10 @@
}
}
 
+   if (node-type == XML_ELEMENT_NODE  (! match_ns(sxe, 
node, sxe-iter.nsprefix))) {
+   goto next_iter;
+   }
+
name = (char *) node-name;
if (!name) {
goto next_iter;
@@ -719,7 +726,7 @@
namelen = xmlStrlen(node-name) + 1;
}
 
-   _get_base_node_value(sxe, node, value TSRMLS_CC);
+   _get_base_node_value(sxe, node, value, 
sxe-iter.nsprefix TSRMLS_CC);
 
h = zend_hash_func(name, namelen);
if (zend_hash_quick_find(rv, name, namelen, h, (void 
**) data_ptr) == SUCCESS) {
@@ -1760,7 +1767,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.158 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.159 $);
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 simplexml.c /ext/standard http_fopen_wrapper.c

2005-08-16 Thread Rolland Santimano
rolland Tue Aug 16 02:05:00 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
/php-src/ext/standard   http_fopen_wrapper.c 
  Log:
  Updated calls to php_trim() to provide arg for returned string type
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.154r2=1.155ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.154 
php-src/ext/simplexml/simplexml.c:1.155
--- php-src/ext/simplexml/simplexml.c:1.154 Fri Aug 12 10:08:25 2005
+++ php-src/ext/simplexml/simplexml.c   Tue Aug 16 02:04:58 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.154 2005/08/12 14:08:25 sebastian Exp $ */
+/* $Id: simplexml.c,v 1.155 2005/08/16 06:04:58 rolland Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -337,7 +337,7 @@
trim_zv = *member;
zval_copy_ctor(trim_zv);
convert_to_string(trim_zv);
-   php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), NULL, 0, 
tmp_zv, 3 TSRMLS_CC);
+   php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), NULL, 0, 
IS_STRING, tmp_zv, 3 TSRMLS_CC);
zval_dtor(trim_zv);
member = tmp_zv;
}
@@ -1736,7 +1736,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.154 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.155 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.99r2=1.100ty=u
Index: php-src/ext/standard/http_fopen_wrapper.c
diff -u php-src/ext/standard/http_fopen_wrapper.c:1.99 
php-src/ext/standard/http_fopen_wrapper.c:1.100
--- php-src/ext/standard/http_fopen_wrapper.c:1.99  Wed Aug  3 10:08:04 2005
+++ php-src/ext/standard/http_fopen_wrapper.c   Tue Aug 16 02:04:59 2005
@@ -19,7 +19,7 @@
|  Sara Golemon [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: http_fopen_wrapper.c,v 1.99 2005/08/03 14:08:04 sniper Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.100 2005/08/16 06:04:59 rolland Exp $ */ 
 
 #include php.h
 #include php_globals.h
@@ -265,7 +265,7 @@
Z_STRLEN_PP(tmpzval)) {
/* Remove newlines and spaces from start and end,
   php_trim will estrndup() */
-   tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), 
NULL, 0, NULL, 3 TSRMLS_CC);
+   tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), 
NULL, 0, IS_STRING, NULL, 3 TSRMLS_CC);
if (strlen(tmp)  0) {
if (!header_init) { /* Remove post headers for 
redirects */
int l = strlen(tmp);
@@ -291,7 +291,7 @@
}
}
efree(tmp_c);
-   tmp_c = php_trim(tmp, strlen(tmp), NULL, 0, 
NULL, 3 TSRMLS_CC);
+   tmp_c = php_trim(tmp, strlen(tmp), NULL, 0, 
IS_STRING, NULL, 3 TSRMLS_CC);
efree(tmp);
tmp = tmp_c;
}

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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/standard http_fopen_wrapper.c

2005-08-16 Thread Andi Gutmans

never mind. i thought you were changing a PHP function :)

At 06:05 AM 8/16/2005 +, Rolland Santimano wrote:

rolland Tue Aug 16 02:05:00 2005 EDT

  Modified files:
/php-src/ext/simplexml  simplexml.c
/php-src/ext/standard   http_fopen_wrapper.c
  Log:
  Updated calls to php_trim() to provide arg for returned string type


http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.154r2=1.155ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.154 
php-src/ext/simplexml/simplexml.c:1.155

--- php-src/ext/simplexml/simplexml.c:1.154 Fri Aug 12 10:08:25 2005
+++ php-src/ext/simplexml/simplexml.c   Tue Aug 16 02:04:58 2005
@@ -18,7 +18,7 @@
   +--+
 */

-/* $Id: simplexml.c,v 1.154 2005/08/12 14:08:25 sebastian Exp $ */
+/* $Id: simplexml.c,v 1.155 2005/08/16 06:04:58 rolland Exp $ */

 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -337,7 +337,7 @@
trim_zv = *member;
zval_copy_ctor(trim_zv);
convert_to_string(trim_zv);
-   php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), 
NULL, 0, tmp_zv, 3 TSRMLS_CC);
+   php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), 
NULL, 0, IS_STRING, tmp_zv, 3 TSRMLS_CC);

zval_dtor(trim_zv);
member = tmp_zv;
}
@@ -1736,7 +1736,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.154 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.155 $);
php_info_print_table_row(2, Schema support,
 #ifdef LIBXML_SCHEMAS_ENABLED
enabled);
http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.99r2=1.100ty=u
Index: php-src/ext/standard/http_fopen_wrapper.c
diff -u php-src/ext/standard/http_fopen_wrapper.c:1.99 
php-src/ext/standard/http_fopen_wrapper.c:1.100
--- php-src/ext/standard/http_fopen_wrapper.c:1.99  Wed Aug  3 
10:08:04 2005

+++ php-src/ext/standard/http_fopen_wrapper.c   Tue Aug 16 02:04:59 2005
@@ -19,7 +19,7 @@
|  Sara Golemon [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: http_fopen_wrapper.c,v 1.99 2005/08/03 14:08:04 sniper Exp $ */
+/* $Id: http_fopen_wrapper.c,v 1.100 2005/08/16 06:04:59 rolland Exp $ */

 #include php.h
 #include php_globals.h
@@ -265,7 +265,7 @@
Z_STRLEN_PP(tmpzval)) {
/* Remove newlines and spaces from start and end,
   php_trim will estrndup() */
-   tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), 
NULL, 0, NULL, 3 TSRMLS_CC);
+   tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), 
NULL, 0, IS_STRING, NULL, 3 TSRMLS_CC);

if (strlen(tmp)  0) {
if (!header_init) { /* Remove post headers for 
redirects */

int l = strlen(tmp);
@@ -291,7 +291,7 @@
}
}
efree(tmp_c);
-   tmp_c = php_trim(tmp, strlen(tmp), NULL, 
0, NULL, 3 TSRMLS_CC);
+   tmp_c = php_trim(tmp, strlen(tmp), NULL, 
0, IS_STRING, NULL, 3 TSRMLS_CC);

efree(tmp);
tmp = tmp_c;
}

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


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



[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2005-07-06 Thread Rasmus Lerdorf
rasmus  Wed Jul  6 23:53:49 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Missing closing folding marker
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.149r2=1.150ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.149 
php-src/ext/simplexml/simplexml.c:1.150
--- php-src/ext/simplexml/simplexml.c:1.149 Thu Jun 30 07:14:56 2005
+++ php-src/ext/simplexml/simplexml.c   Wed Jul  6 23:53:47 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.149 2005/06/30 11:14:56 sniper Exp $ */
+/* $Id: simplexml.c,v 1.150 2005/07/07 03:53:47 rasmus Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1183,6 +1183,7 @@
sxe-iter.nsprefix = NULL;
}
 }
+/* }}} */
 
 /* {{{ sxe_object_free_storage()
  */
@@ -1735,7 +1736,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.149 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.150 $);
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 simplexml.c

2005-06-17 Thread Jani Taskinen
sniper  Fri Jun 17 07:35:23 2005 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Use the new dependency system
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.147r2=1.148ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.147 
php-src/ext/simplexml/simplexml.c:1.148
--- php-src/ext/simplexml/simplexml.c:1.147 Sun Dec  5 07:02:35 2004
+++ php-src/ext/simplexml/simplexml.c   Fri Jun 17 07:35:22 2005
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.147 2004/12/05 12:02:35 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.148 2005/06/17 11:35:22 sniper Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1652,8 +1652,14 @@
{NULL, NULL, NULL}
 };
 
+static zend_module_dep simplexml_deps[] = {
+   ZEND_MOD_REQUIRED(libxml)
+   {NULL, NULL, NULL}
+};
+
 zend_module_entry simplexml_module_entry = {
-   STANDARD_MODULE_HEADER,
+   STANDARD_MODULE_HEADER_EX, NULL,
+   simplexml_deps,
SimpleXML,
simplexml_functions,
PHP_MINIT(simplexml),
@@ -1729,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.147 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.148 $);
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 simplexml.c

2004-12-05 Thread Rob Richards
rrichards   Sun Dec  5 07:02:35 2004 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  add optional parameter to pass libxml document load options
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.146r2=1.147ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.146 
php-src/ext/simplexml/simplexml.c:1.147
--- php-src/ext/simplexml/simplexml.c:1.146 Mon Aug 30 13:29:22 2004
+++ php-src/ext/simplexml/simplexml.c   Sun Dec  5 07:02:35 2004
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.146 2004/08/30 17:29:22 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.147 2004/12/05 12:02:35 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1260,7 +1260,7 @@
 }
 /* }}} */
 
-/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string 
class_name])
+/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string 
class_name [, int options]])
Load a filename and return a simplexml_element object to allow for 
processing */
 PHP_FUNCTION(simplexml_load_file)
 {
@@ -1269,14 +1269,19 @@
int filename_len;
xmlDocPtr   docp;
char   *classname = ;
-   int classname_len = 0;
+   int classname_len = 0, options=0;
zend_class_entry *ce= sxe_class_entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|s, filename, 
filename_len, classname, classname_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, filename, 
filename_len, classname, classname_len, options) == FAILURE) {
return;
}
 
+#if LIBXML_VERSION = 20600
+   docp = xmlReadFile(filename, NULL, options);
+#else
docp = xmlParseFile(filename);
+#endif
+
if (! docp) {
RETURN_FALSE;
}
@@ -1298,7 +1303,7 @@
 }
 /* }}} */
 
-/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name])
+/* {{{ proto simplemxml_element simplexml_load_string(string data [, string 
class_name [, int options]])
Load a string and return a simplexml_element object to allow for processing 
*/
 PHP_FUNCTION(simplexml_load_string)
 {
@@ -1307,14 +1312,19 @@
int data_len;
xmlDocPtr   docp;
char   *classname = ;
-   int classname_len = 0;
+   int classname_len = 0, options=0;
zend_class_entry *ce= sxe_class_entry;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|s, data, 
data_len, classname, classname_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sl, data, 
data_len, classname, classname_len, options) == FAILURE) {
return;
}
 
+#if LIBXML_VERSION = 20600
+   docp = xmlReadMemory(data, data_len, NULL, NULL, options);
+#else
docp = xmlParseMemory(data, data_len);
+#endif
+
if (! docp) {
RETURN_FALSE;
}
@@ -1719,7 +1729,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.146 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.147 $);
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 simplexml.c

2004-08-06 Thread Sara Golemon
pollita Fri Aug  6 12:36:01 2004 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  ZTS Fix
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.144r2=1.145ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.144 php-src/ext/simplexml/simplexml.c:1.145
--- php-src/ext/simplexml/simplexml.c:1.144 Thu Aug  5 19:57:51 2004
+++ php-src/ext/simplexml/simplexml.c   Fri Aug  6 12:36:00 2004
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.144 2004/08/05 23:57:51 iliaa Exp $ */
+/* $Id: simplexml.c,v 1.145 2004/08/06 16:36:00 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -271,8 +271,7 @@
 
 /* {{{ change_node_zval()
  */
-static void
-change_node_zval(xmlNodePtr node, zval *value)
+static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC)
 {
zval value_copy;
 
@@ -418,7 +417,7 @@
xmlUnlinkNode(tempnode);
php_libxml_node_free_resource((xmlNodePtr) tempnode 
TSRMLS_CC);
}
-   change_node_zval(newnode, value);
+   change_node_zval(newnode, value TSRMLS_CC);
} else if (counter  1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot assign to 
an array of nodes (duplicate subnodes or attr detected)\n);
} else {
@@ -1679,7 +1678,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.144 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.145 $);
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 simplexml.c

2004-08-04 Thread Zeev Suraski
zeevWed Aug  4 10:41:56 2004 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fix prototypes
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.141r2=1.142ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.141 php-src/ext/simplexml/simplexml.c:1.142
--- php-src/ext/simplexml/simplexml.c:1.141 Sun Jul 25 10:59:21 2004
+++ php-src/ext/simplexml/simplexml.c   Wed Aug  4 10:41:56 2004
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.141 2004/07/25 14:59:21 chregu Exp $ */
+/* $Id: simplexml.c,v 1.142 2004/08/04 14:41:56 zeev Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -764,8 +764,8 @@
 }
 /* }}} */
 
-/* {{{ xpath()
- */
+/* {{{ array SimpleXMLElement::xpath(string path)
+   Runs XPath query on the XML data */
 SXE_METHOD(xpath)
 {
php_sxe_object*sxe;
@@ -868,8 +868,8 @@
 
 /* }}} */
 
-/* {{{ proto asXML([string filename])
- */
+/* {{{ proto string SimpleXMLElement::asXML([string filename])
+   Return a well-formed XML string based on SimpleXML element */
 SXE_METHOD(asXML)
 {
php_sxe_object *sxe;
@@ -941,8 +941,8 @@
 }
 /* }}} */
 
-/* {{{ simplexml_children()
- */
+/* {{{ proto object SimpleXMLElement::children()
+   Finds children of given node */
 SXE_METHOD(children)
 {
php_sxe_object *sxe;
@@ -963,8 +963,8 @@
 }
 /* }}} */
 
-/* {{{ simplexml_attributes()
- */
+/* {{{ proto array SimpleXMLElement::attributes([string ns])
+   Identifies an element's attributes */
 SXE_METHOD(attributes)
 {
php_sxe_object *sxe;
@@ -1303,6 +1303,9 @@
 }
 /* }}} */
 
+
+/* {{{ proto SimpleXMLElement::__construct()
+   SimpleXMLElement constructor */
 SXE_METHOD(__construct)
 {
php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
@@ -1327,6 +1330,8 @@
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, 
xmlDocGetRootElement(docp), NULL TSRMLS_CC);
 }
+/* }}} */
+
 
 typedef struct {
zend_object_iterator  intern;
@@ -1675,7 +1680,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.141 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.142 $);
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 simplexml.c

2004-08-04 Thread Antony Dovgal
tony2001Wed Aug  4 10:57:40 2004 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  nuke unused variable
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.142r2=1.143ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.142 php-src/ext/simplexml/simplexml.c:1.143
--- php-src/ext/simplexml/simplexml.c:1.142 Wed Aug  4 10:41:56 2004
+++ php-src/ext/simplexml/simplexml.c   Wed Aug  4 10:57:40 2004
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.142 2004/08/04 14:41:56 zeev Exp $ */
+/* $Id: simplexml.c,v 1.143 2004/08/04 14:57:40 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -847,7 +847,6 @@
 SXE_METHOD(registerXPathNamespace)
 {
php_sxe_object*sxe;
-   zval *id;
int prefix_len, ns_uri_len;
char *prefix, *ns_uri;
 
@@ -1680,7 +1679,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.142 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.143 $);
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



Re: [PHP-CVS] cvs: php-src /ext/simplexml simplexml.c /ext/simplexml/tests 001.phpt 002.phpt 003.phpt 004.phpt 007.phpt 008.phpt 009.phpt 010.phpt 014.phpt 014a.phpt 014b.phpt 015.phpt 016.phpt

2004-03-29 Thread Sterling Hughes
wtf?

-sterling

On Mar 29, 2004, at 11:58 AM, Marcus Boerger wrote:

helly		Mon Mar 29 14:58:01 2004 EDT

  Modified files:
/php-src/ext/simplexml  simplexml.c
/php-src/ext/simplexml/tests001.phpt 002.phpt 003.phpt 004.phpt
007.phpt 008.phpt 009.phpt 010.phpt
014.phpt 014a.phpt 014b.phpt 015.phpt
016.phpt
  Log:
  Fix class names
helly-20040329145801.txt--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-CVS] cvs: php-src /ext/simplexml simplexml.c

2004-03-23 Thread George Schlossnagle
gschlossnagle   Wed Mar 24 00:04:26 2004 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  fixed non-existent elements check
  ref: http://news.php.net/article.php?group=php.internalsarticle=8660
  
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.135r2=1.136ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.135 php-src/ext/simplexml/simplexml.c:1.136
--- php-src/ext/simplexml/simplexml.c:1.135 Sun Mar 21 13:28:38 2004
+++ php-src/ext/simplexml/simplexml.c   Wed Mar 24 00:04:26 2004
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.135 2004/03/21 18:28:38 stas Exp $ */
+/* $Id: simplexml.c,v 1.136 2004/03/24 05:04:26 gschlossnagle Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -511,7 +511,23 @@
}
node = sxe_get_element_by_offset(sxe, 
Z_LVAL_P(member), node);
}
-
+   else {
+   if (Z_TYPE_P(member) != IS_STRING) {
+   zval tmp_zv = *member;
+   zval_copy_ctor(tmp_zv);
+   member = tmp_zv;
+   convert_to_string(member);
+   }
+   node = node-children;
+   while (node) {
+   xmlNodePtr nnext;
+   nnext = node-next;
+   if (!xmlStrcmp(node-name, 
Z_STRVAL_P(member))) {
+   break;
+   }
+   node = nnext;
+   }
+}
if (node) {
exists = 1;
}
@@ -1634,7 +1650,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.135 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.136 $);
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 simplexml.c

2004-03-16 Thread Derick Rethans
derick  Tue Mar 16 16:39:44 2004 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  - Fixed compilation on the 'broken' IRIX native compiler.
  
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.133r2=1.134ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.133 php-src/ext/simplexml/simplexml.c:1.134
--- php-src/ext/simplexml/simplexml.c:1.133 Mon Mar  8 13:05:40 2004
+++ php-src/ext/simplexml/simplexml.c   Tue Mar 16 16:39:43 2004
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.133 2004/03/08 18:05:40 helly Exp $ */
+/* $Id: simplexml.c,v 1.134 2004/03/16 21:39:43 derick Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1279,7 +1279,7 @@
php_std_error_handling();
docp = xmlParseMemory(data, data_len);
if (!docp) {
-   (php_libxml_node_object *)sxe-document = NULL;
+   ((php_libxml_node_object *)sxe)-document = NULL;
zend_throw_exception(zend_exception_get_default(), String could not 
be parsed as XML, 0 TSRMLS_CC);
return;
}
@@ -1634,7 +1634,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.133 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.134 $);
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 simplexml.c

2004-02-13 Thread Rob Richards
rrichards   Fri Feb 13 10:05:19 2004 EDT

  Modified files:  
/php-src/ext/simplexml  simplexml.c 
  Log:
  Fix bug #27237: Working with simplexml crashes apache2
  object dtor must be used to cleanup iterator data correctly
  Fix asXML() outputing incorrect node
  
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.130r2=1.131ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.130 php-src/ext/simplexml/simplexml.c:1.131
--- php-src/ext/simplexml/simplexml.c:1.130 Thu Feb 12 18:39:46 2004
+++ php-src/ext/simplexml/simplexml.c   Fri Feb 13 10:05:18 2004
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: simplexml.c,v 1.130 2004/02/12 23:39:46 derick Exp $ */
+/* $Id: simplexml.c,v 1.131 2004/02/13 15:05:18 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -852,6 +852,7 @@
 
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
GET_NODE(sxe, node);
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
if (node) {
if (XML_DOCUMENT_NODE == node-parent-type) {
@@ -874,6 +875,7 @@
 
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
GET_NODE(sxe, node);
+   node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
 
if (node) {
if (XML_DOCUMENT_NODE == node-parent-type) {
@@ -1088,27 +1090,41 @@
 }
 /* }}} */
 
-/* {{{ sxe_object_free_storage()
+/* {{{ sxe_object_dtor()
  */
-static void sxe_object_free_storage(void *object TSRMLS_DC)
+static void sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC)
 {
+   /* dtor required to cleanup iterator related data properly */
+
php_sxe_object *sxe;
 
sxe = (php_sxe_object *) object;
 
-   zend_hash_destroy(sxe-zo.properties);
-   FREE_HASHTABLE(sxe-zo.properties);
-
if (sxe-iter.data) {
zval_ptr_dtor(sxe-iter.data);
+   sxe-iter.data = NULL;
}
 
if (sxe-iter.name) {
xmlFree(sxe-iter.name);
+   sxe-iter.name = NULL;
}
if (sxe-iter.nsprefix) {
xmlFree(sxe-iter.nsprefix);
+   sxe-iter.nsprefix = NULL;
}
+}
+
+/* {{{ sxe_object_free_storage()
+ */
+static void sxe_object_free_storage(void *object TSRMLS_DC)
+{
+   php_sxe_object *sxe;
+
+   sxe = (php_sxe_object *) object;
+
+   zend_hash_destroy(sxe-zo.properties);
+   FREE_HASHTABLE(sxe-zo.properties);
 
php_libxml_node_decrement_resource((php_libxml_node_object *)sxe TSRMLS_CC);
 
@@ -1152,7 +1168,7 @@
 {
zend_object_value rv;
 
-   rv.handle = zend_objects_store_put(intern, NULL, 
(zend_objects_free_object_storage_t)sxe_object_free_storage, sxe_object_clone 
TSRMLS_CC);
+   rv.handle = zend_objects_store_put(intern, sxe_object_dtor, 
(zend_objects_free_object_storage_t)sxe_object_free_storage, sxe_object_clone 
TSRMLS_CC);
rv.handlers = (zend_object_handlers *) sxe_object_handlers;
 
return rv;
@@ -1364,7 +1380,10 @@
 {
php_sxe_iterator *iterator = (php_sxe_iterator *)iter;
 
-   zval_ptr_dtor((zval**)iterator-intern.data);
+   /* cleanup handled in sxe_object_dtor as we dont always have an iterator 
wrapper */
+   if (iterator-intern.data) {
+   zval_ptr_dtor((zval**)iterator-intern.data);
+   }
 
efree(iterator);
 }
@@ -1602,7 +1621,7 @@
 {
php_info_print_table_start();
php_info_print_table_header(2, Simplexml support, enabled);
-   php_info_print_table_row(2, Revision, $Revision: 1.130 $);
+   php_info_print_table_row(2, Revision, $Revision: 1.131 $);
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



  1   2   >