From 62b1d2cb69dddfbc752b6a684d94bb520742a851 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 12 May 2020 22:54:43 +0200 Subject: [PATCH] Fix [-Wundef] warning in DOM extension --- ext/dom/attr.c | 2 +- ext/dom/cdatasection.c | 2 +- ext/dom/characterdata.c | 2 +- ext/dom/comment.c | 2 +- ext/dom/document.c | 10 +++++----- ext/dom/documentfragment.c | 2 +- ext/dom/documenttype.c | 2 +- ext/dom/dom_ce.h | 2 +- ext/dom/dom_iterators.c | 2 +- ext/dom/dom_properties.h | 2 +- ext/dom/domexception.c | 2 +- ext/dom/domimplementation.c | 2 +- ext/dom/element.c | 2 +- ext/dom/entity.c | 2 +- ext/dom/entityreference.c | 2 +- ext/dom/namednodemap.c | 2 +- ext/dom/node.c | 2 +- ext/dom/nodelist.c | 2 +- ext/dom/notation.c | 2 +- ext/dom/parentnode.c | 2 +- ext/dom/php_dom.c | 24 ++++++++++++------------ ext/dom/php_dom.h | 8 ++++---- ext/dom/php_dom.stub.php | 6 +++--- ext/dom/processinginstruction.c | 2 +- ext/dom/text.c | 2 +- ext/dom/xpath.c | 4 ++-- 26 files changed, 47 insertions(+), 47 deletions(-) diff --git a/ext/dom/attr.c b/ext/dom/attr.c index f6612e791a7..a89cce57500 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -21,7 +21,7 @@ #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" diff --git a/ext/dom/cdatasection.c b/ext/dom/cdatasection.c index bd02af70425..72bf77a04f2 100644 --- a/ext/dom/cdatasection.c +++ b/ext/dom/cdatasection.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c index ef458460f6a..b43636a8a4b 100644 --- a/ext/dom/characterdata.c +++ b/ext/dom/characterdata.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/comment.c b/ext/dom/comment.c index 32d6271c38d..44cde901667 100644 --- a/ext/dom/comment.c +++ b/ext/dom/comment.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/document.c b/ext/dom/document.c index 919c5940868..e355e0f134c 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" #include #ifdef LIBXML_SCHEMAS_ENABLED @@ -1225,9 +1225,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, size_t so /* If loading from memory, we need to set the base directory for the document */ if (mode != DOM_LOAD_FILE) { -#if HAVE_GETCWD +#ifdef HAVE_GETCWD directory = VCWD_GETCWD(resolved_path, MAXPATHLEN); -#elif HAVE_GETWD +#elif defined(HAVE_GETWD) directory = VCWD_GETWD(resolved_path); #endif if (directory) { @@ -1621,7 +1621,7 @@ PHP_METHOD(DOMDocument, validate) } /* }}} */ -#if defined(LIBXML_SCHEMAS_ENABLED) +#ifdef LIBXML_SCHEMAS_ENABLED static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ { zval *id; @@ -1819,7 +1819,7 @@ PHP_METHOD(DOMDocument, relaxNGValidateSource) #endif -#if defined(LIBXML_HTML_ENABLED) +#ifdef LIBXML_HTML_ENABLED static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ { diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c index bdef3396367..14cdaf1d214 100644 --- a/ext/dom/documentfragment.c +++ b/ext/dom/documentfragment.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c index 1e7857a6483..e910cf40097 100644 --- a/ext/dom/documenttype.c +++ b/ext/dom/documenttype.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* {{{ name string diff --git a/ext/dom/dom_ce.h b/ext/dom/dom_ce.h index 4fea77b8e29..784012bf59a 100644 --- a/ext/dom/dom_ce.h +++ b/ext/dom/dom_ce.h @@ -36,7 +36,7 @@ extern PHP_DOM_EXPORT zend_class_entry *dom_notation_class_entry; extern PHP_DOM_EXPORT zend_class_entry *dom_entity_class_entry; extern PHP_DOM_EXPORT zend_class_entry *dom_entityreference_class_entry; extern PHP_DOM_EXPORT zend_class_entry *dom_processinginstruction_class_entry; -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED extern PHP_DOM_EXPORT zend_class_entry *dom_xpath_class_entry; #endif extern PHP_DOM_EXPORT zend_class_entry *dom_namespace_node_class_entry; diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index 6a898611079..bd83114bd9f 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" #include "dom_ce.h" diff --git a/ext/dom/dom_properties.h b/ext/dom/dom_properties.h index b4b04013569..f972bffe960 100644 --- a/ext/dom/dom_properties.h +++ b/ext/dom/dom_properties.h @@ -132,7 +132,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval); /* text properties */ int dom_text_whole_text_read(dom_object *obj, zval *retval); -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED /* xpath properties */ int dom_xpath_document_read(dom_object *obj, zval *retval); int dom_xpath_register_node_ns_read(dom_object *obj, zval *retval); diff --git a/ext/dom/domexception.c b/ext/dom/domexception.c index f0f5e7d765e..0fb4d57c043 100644 --- a/ext/dom/domexception.c +++ b/ext/dom/domexception.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/domimplementation.c b/ext/dom/domimplementation.c index c5492356fbe..1dfe95ab619 100644 --- a/ext/dom/domimplementation.c +++ b/ext/dom/domimplementation.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/element.c b/ext/dom/element.c index c76592a72ae..cd67e214a59 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/entity.c b/ext/dom/entity.c index d00a969c086..7ad43a1ee33 100644 --- a/ext/dom/entity.c +++ b/ext/dom/entity.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" diff --git a/ext/dom/entityreference.c b/ext/dom/entityreference.c index 3b8f2dac94e..370d4510cee 100644 --- a/ext/dom/entityreference.c +++ b/ext/dom/entityreference.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/namednodemap.c b/ext/dom/namednodemap.c index 9e322d8edd0..18775d7ef13 100644 --- a/ext/dom/namednodemap.c +++ b/ext/dom/namednodemap.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/node.c b/ext/dom/node.c index fe09c1c940a..f2da0d92b75 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index d6845c32ada..502c75d0aac 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/notation.c b/ext/dom/notation.c index 468bbad4e0c..f1e0c1ba388 100644 --- a/ext/dom/notation.c +++ b/ext/dom/notation.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/parentnode.c b/ext/dom/parentnode.c index 76263918be2..a7627cb84c1 100644 --- a/ext/dom/parentnode.c +++ b/ext/dom/parentnode.c @@ -21,7 +21,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* {{{ firstElementChild DomParentNode diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index c7b2103a0f5..9dc50ac2877 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -21,7 +21,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "ext/standard/php_rand.h" #include "php_dom.h" #include "php_dom_arginfo.h" @@ -53,7 +53,7 @@ PHP_DOM_EXPORT zend_class_entry *dom_notation_class_entry; PHP_DOM_EXPORT zend_class_entry *dom_entity_class_entry; PHP_DOM_EXPORT zend_class_entry *dom_entityreference_class_entry; PHP_DOM_EXPORT zend_class_entry *dom_processinginstruction_class_entry; -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED PHP_DOM_EXPORT zend_class_entry *dom_xpath_class_entry; #endif PHP_DOM_EXPORT zend_class_entry *dom_namespace_node_class_entry; @@ -61,7 +61,7 @@ PHP_DOM_EXPORT zend_class_entry *dom_namespace_node_class_entry; zend_object_handlers dom_object_handlers; zend_object_handlers dom_nnodemap_object_handlers; -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED zend_object_handlers dom_xpath_object_handlers; #endif @@ -81,7 +81,7 @@ static HashTable dom_notation_prop_handlers; static HashTable dom_entity_prop_handlers; static HashTable dom_processinginstruction_prop_handlers; static HashTable dom_namespace_node_prop_handlers; -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED static HashTable dom_xpath_prop_handlers; #endif /* }}} */ @@ -551,7 +551,7 @@ static zval *dom_nodelist_read_dimension(zend_object *object, zval *offset, int static int dom_nodelist_has_dimension(zend_object *object, zval *member, int check_empty); static zend_object *dom_objects_store_clone_obj(zend_object *zobject); static void dom_nnodemap_object_dtor(zend_object *object); -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED void dom_xpath_objects_free_storage(zend_object *object); #endif @@ -780,7 +780,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0); zend_hash_add_ptr(&classes, ce.name, &dom_processinginstruction_prop_handlers); -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED memcpy(&dom_xpath_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers)); dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, dom) + XtOffsetOf(dom_object, std); dom_xpath_object_handlers.free_obj = dom_xpath_objects_free_storage; @@ -859,13 +859,13 @@ PHP_MINFO_FUNCTION(dom) php_info_print_table_row(2, "DOM/XML", "enabled"); php_info_print_table_row(2, "DOM/XML API Version", DOM_API_VERSION); php_info_print_table_row(2, "libxml Version", LIBXML_DOTTED_VERSION); -#if defined(LIBXML_HTML_ENABLED) +#ifdef LIBXML_HTML_ENABLED php_info_print_table_row(2, "HTML Support", "enabled"); #endif -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED php_info_print_table_row(2, "XPath Support", "enabled"); #endif -#if defined(LIBXML_XPTR_ENABLED) +#ifdef LIBXML_XPTR_ENABLED php_info_print_table_row(2, "XPointer Support", "enabled"); #endif #ifdef LIBXML_SCHEMAS_ENABLED @@ -892,7 +892,7 @@ PHP_MSHUTDOWN_FUNCTION(dom) /* {{{ */ zend_hash_destroy(&dom_notation_prop_handlers); zend_hash_destroy(&dom_entity_prop_handlers); zend_hash_destroy(&dom_processinginstruction_prop_handlers); -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED zend_hash_destroy(&dom_xpath_prop_handlers); #endif zend_hash_destroy(&classes); @@ -941,7 +941,7 @@ void node_list_unlink(xmlNodePtr node) } /* }}} end node_list_unlink */ -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED /* {{{ dom_xpath_objects_free_storage */ void dom_xpath_objects_free_storage(zend_object *object) { @@ -1035,7 +1035,7 @@ zend_object *dom_objects_new(zend_class_entry *class_type) } /* }}} */ -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED /* {{{ zend_object dom_xpath_objects_new(zend_class_entry *class_type) */ zend_object *dom_xpath_objects_new(zend_class_entry *class_type) { diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index ec01196af7c..7a0a5e7d72e 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -34,15 +34,15 @@ extern zend_module_entry dom_module_entry; #include #include #include -#if defined(LIBXML_HTML_ENABLED) +#ifdef LIBXML_HTML_ENABLED #include #include #endif -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED #include #include #endif -#if defined(LIBXML_XPTR_ENABLED) +#ifdef LIBXML_XPTR_ENABLED #include #endif #ifdef PHP_WIN32 @@ -99,7 +99,7 @@ dom_object *dom_object_get_data(xmlNodePtr obj); dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document); zend_object *dom_objects_new(zend_class_entry *class_type); zend_object *dom_nnodemap_objects_new(zend_class_entry *class_type); -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED zend_object *dom_xpath_objects_new(zend_class_entry *class_type); #endif int dom_get_strict_error(php_libxml_ref_obj *document); diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 3d77b136c79..a254df125c3 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -306,7 +306,7 @@ class DOMDocument implements DOMParentNode /** @return int|false */ public function save(string $filename, int $options = 0) {} -#if defined(LIBXML_HTML_ENABLED) +#ifdef LIBXML_HTML_ENABLED /** @return DOMDocument|bool */ public function loadHTML(string $source, int $options = 0) {} @@ -323,7 +323,7 @@ class DOMDocument implements DOMParentNode /** @return string|false */ public function saveXML(?DOMNode $node = null, int $options = 0) {} -#if defined(LIBXML_SCHEMAS_ENABLED) +#ifdef LIBXML_SCHEMAS_ENABLED /** @return bool */ public function schemaValidate(string $filename, int $flags = 0) {} @@ -407,7 +407,7 @@ class DOMProcessingInstruction public function __construct(string $name, string $value = "") {} } -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED class DOMXPath { public function __construct(DOMDocument $doc, bool $registerNodeNS = true) {} diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c index c9718e24bba..7d4a080953b 100644 --- a/ext/dom/processinginstruction.c +++ b/ext/dom/processinginstruction.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" /* diff --git a/ext/dom/text.c b/ext/dom/text.c index 0258598f061..63651985cae 100644 --- a/ext/dom/text.c +++ b/ext/dom/text.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" #include "dom_ce.h" diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index fbb8f39afb7..f453ca72f2f 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -20,7 +20,7 @@ #endif #include "php.h" -#if HAVE_LIBXML && HAVE_DOM +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" #define PHP_DOM_XPATH_QUERY 0 @@ -30,7 +30,7 @@ * class DOMXPath */ -#if defined(LIBXML_XPATH_ENABLED) +#ifdef LIBXML_XPATH_ENABLED static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int type) /* {{{ */ {