]> granicus.if.org Git - php/commitdiff
- make it compile with libxml2 2.5 again
authorChristian Stocker <chregu@php.net>
Mon, 23 Feb 2004 08:21:07 +0000 (08:21 +0000)
committerChristian Stocker <chregu@php.net>
Mon, 23 Feb 2004 08:21:07 +0000 (08:21 +0000)
- disable xml_parser_create_ns with libxml2 2.5 for the time being
- the #if s can be removed, once we insist on libxml2 2.6

ext/xml/compat.c
ext/xml/xml.c

index 8c5de13a2cdc5ea1561096879897a5c43f461577..7814465058d98baf4b12fd1e4c3c5ab62177a9ac 100644 (file)
@@ -63,6 +63,7 @@ _start_element_handler(void *user, const xmlChar *name, const xmlChar **attribut
        xmlFree(qualified_name);
 }
 
+#if LIBXML_VERSION >= 20600 
 static void
 _start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes)
 {
@@ -77,6 +78,7 @@ _start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix
 
        xmlFree(qualified_name);
 }
+#endif
 
 static void
 _namespace_handler(XML_Parser parser, xmlNsPtr nsptr)
@@ -104,6 +106,7 @@ _end_element_handler(void *user, const xmlChar *name)
        xmlFree(qualified_name);
 }
 
+#if LIBXML_VERSION >= 20600 
 static void
 _end_element_handler_ns(void *user, const xmlChar *name, const xmlChar * prefix, const xmlChar *URI)
 {
@@ -120,6 +123,7 @@ _end_element_handler_ns(void *user, const xmlChar *name, const xmlChar * prefix,
 
        xmlFree(qualified_name);
 }
+#endif
 
 static void
 _cdata_handler(void *user, const xmlChar *cdata, int cdata_len)
@@ -268,11 +272,14 @@ php_xml_compat_handlers = {
        NULL,  /* getParameterEntity */
        _cdata_handler, /* cdataBlock */
        NULL, /* externalSubset */
-       1,
+       1
+#if LIBXML_VERSION >= 20600 
+       ,
        NULL,
        _start_element_handler_ns,
        _end_element_handler_ns,
        NULL
+#endif
        
 };
 
@@ -314,7 +321,9 @@ XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *m
        parser->parser->replaceEntities = 1;
        if (sep != NULL) {
                parser->use_namespace = 1;
+#if LIBXML_VERSION >= 20600
                parser->parser->sax2 = 1;
+#endif
                parser->_ns_seperator = xmlStrdup(sep);
        }
        return parser;
@@ -396,6 +405,7 @@ XML_SetEndNamespaceDeclHandler(XML_Parser parser, XML_EndNamespaceDeclHandler en
 PHPAPI int
 XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final)
 {
+#if LIBXML_VERSION >= 20600
        int error;
        error = xmlParseChunk(parser->parser, data, data_len, is_final);
        if (!error) {
@@ -405,6 +415,9 @@ XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final)
        } else {
                return 1;
        }
+#else
+       return !xmlParseChunk(parser->parser, data, data_len, is_final);
+#endif
 }
 
 PHPAPI int
index 728a811f47e4d43bbc1e93004b757dd98aa84514..f9ddc740deecc61a4a42026ab07e92bae57337a8 100644 (file)
@@ -1109,7 +1109,11 @@ PHP_FUNCTION(xml_parser_create)
    Create an XML parser */
 PHP_FUNCTION(xml_parser_create_ns)
 {
+#if defined(HAVE_LIBXML) && defined(HAVE_XML) && !defined(HAVE_LIBEXPAT) && LIBXML_VERSION < 20600 
+       php_error_docref(NULL TSRMLS_CC, E_ERROR, "is broken with libxml2 %d. Please upgrade to libxml2 2.6", LIBXML_DOTTED_VERSION);
+#else
        php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+#endif
 }
 /* }}} */