moriyoshi               Wed Oct 29 12:50:57 2003 EDT

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  Do not use convert_to_*_ex() for ordinary zval pointers.
  
  
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.76 php-src/ext/simplexml/simplexml.c:1.77
--- php-src/ext/simplexml/simplexml.c:1.76      Wed Oct 29 07:06:51 2003
+++ php-src/ext/simplexml/simplexml.c   Wed Oct 29 12:50:56 2003
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.76 2003/10/29 12:06:51 helly Exp $ */
+/* $Id: simplexml.c,v 1.77 2003/10/29 17:50:56 moriyoshi Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -129,6 +129,14 @@
        xmlNodePtr      node;
        xmlAttrPtr      attr;
        int             counter = 0;
+       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);
+       }
 
        MAKE_STD_ZVAL(return_value);
        ZVAL_NULL(return_value);
@@ -206,6 +214,10 @@
        return_value->refcount = 0;
        return_value->is_ref = 0;
 
+       if (member == &tmp_zv) {
+               zval_dtor(&tmp_zv);
+       }
+
        return return_value;
 }
 /* }}} */
@@ -223,7 +235,6 @@
  */
 static zval *sxe_dimension_read(zval *object, zval *offset TSRMLS_DC)
 {
-       convert_to_string_ex(&offset);
        return sxe_prop_dim_read(object, offset, 0, 1, 0 TSRMLS_CC);
 }
 /* }}} */
@@ -261,6 +272,14 @@
        xmlAttrPtr      attr = NULL;
        int             counter = 0;
        int             is_attr = 0;
+       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);
+       }
 
        name = Z_STRVAL_P(member);
        sxe = php_sxe_fetch_object(object TSRMLS_CC);
@@ -310,6 +329,10 @@
                        php_error(E_WARNING, "Cannot create new atrribute\n");
                }
        }
+
+       if (member == &tmp_zv) {
+               zval_dtor(&tmp_zv);
+       }
 }
 /* }}} */
 
@@ -325,7 +348,6 @@
  */
 static void sxe_dimension_write(zval *object, zval *offset, zval *value TSRMLS_DC)
 {
-       convert_to_string_ex(&offset);
        sxe_prop_dim_write(object, offset, value, 0, 1 TSRMLS_CC);
 }
 /* }}} */
@@ -381,6 +403,14 @@
        xmlNodePtr      nnext;
        xmlAttrPtr      attr;
        xmlAttrPtr      anext;
+       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);
+       }
 
        sxe = php_sxe_fetch_object(object TSRMLS_CC);
 
@@ -416,6 +446,10 @@
                        }
                }
        }
+
+       if (member == &tmp_zv) {
+               zval_dtor(&tmp_zv);
+       }
 }
 /* }}} */
 
@@ -432,7 +466,6 @@
  */
 static void sxe_dimension_delete(zval *object, zval *offset TSRMLS_DC)
 {
-       convert_to_string_ex(&offset);
        sxe_prop_dim_delete(object, offset, 1, 1 TSRMLS_CC);
 }
 /* }}} */
@@ -654,12 +687,12 @@
 simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type)
 {
        php_sxe_object         *sxe;
-       zval                   *source;
+       zval                   **source;
        xmlSchemaParserCtxtPtr  parser;
        xmlSchemaPtr            sptr;
        xmlSchemaValidCtxtPtr   vptr;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) 
{
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", source) == FAILURE) {
                return;
        }
 
@@ -667,17 +700,17 @@
 
        switch (type) {
                case SCHEMA_FILE:
-                       convert_to_string_ex(&source);
-                       parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
+                       convert_to_string_ex(source);
+                       parser = xmlSchemaNewParserCtxt(Z_STRVAL_PP(source));
                        if (parser == NULL) {
-                               php_error_docref1(NULL TSRMLS_CC, Z_STRVAL_P(source), 
E_WARNING, "Unable to load XML Schema file");
+                               php_error_docref1(NULL TSRMLS_CC, Z_STRVAL_PP(source), 
E_WARNING, "Unable to load XML Schema file");
                                RETURN_FALSE;
                        }
                        sptr = xmlSchemaParse(parser);
                        break;
                case SCHEMA_BLOB:
-                       convert_to_string_ex(&source);
-                       parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), 
Z_STRLEN_P(source));
+                       convert_to_string_ex(source);
+                       parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_PP(source), 
Z_STRLEN_PP(source));
                        sptr = xmlSchemaParse(parser);
                        break;
                default:
@@ -1360,7 +1393,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.76 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.77 $");
        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

Reply via email to