From 3669316ad137d8e8c9dd3de7b26e57819cc57a78 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 16 Nov 2023 13:34:03 +0100 Subject: [PATCH 001/504] Bump version --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4fac7b27a..aca3c56e3 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) m4_define([MAJOR_VERSION], 2) -m4_define([MINOR_VERSION], 12) +m4_define([MINOR_VERSION], 13) m4_define([MICRO_VERSION], 0) AC_INIT([libxml2],[MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION]) From f92ea2ccecdb94cabd40c4df1a2e7f35dd7bd4cb Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 18 Nov 2023 14:36:41 +0100 Subject: [PATCH 002/504] tests: Fix build with older MSVC Regressed in 9b5cce7a. Fixes #620. --- runsuite.c | 1 + runtest.c | 2 +- runxmlconf.c | 1 + testapi.c | 1 + testrecurse.c | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/runsuite.c b/runsuite.c index c1d35ad06..a36a5f3d3 100644 --- a/runsuite.c +++ b/runsuite.c @@ -6,6 +6,7 @@ * daniel@veillard.com */ +#include "config.h" #include #include #include diff --git a/runtest.c b/runtest.c index fe896b722..ff65fe86f 100644 --- a/runtest.c +++ b/runtest.c @@ -11,7 +11,7 @@ * daniel@veillard.com */ -#include "config.h" +#include "libxml.h" #include #ifdef HAVE_UNISTD_H #include diff --git a/runxmlconf.c b/runxmlconf.c index 3053f6a3a..b5c3fd8dd 100644 --- a/runxmlconf.c +++ b/runxmlconf.c @@ -6,6 +6,7 @@ * daniel@veillard.com */ +#include "config.h" #include #include diff --git a/testapi.c b/testapi.c index 2f17c935e..0a0aadffe 100644 --- a/testapi.c +++ b/testapi.c @@ -11,6 +11,7 @@ /* Disable deprecation warnings */ #define XML_DEPRECATED +#include "config.h" #include #include #include diff --git a/testrecurse.c b/testrecurse.c index c5832905a..d76d80acc 100644 --- a/testrecurse.c +++ b/testrecurse.c @@ -10,6 +10,7 @@ * daniel@veillard.com */ +#include "config.h" #include #include From 1ac88300c1eb156697d12c8b1f6017cb20db0516 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 18 Nov 2023 12:21:38 -0500 Subject: [PATCH 003/504] fix: pthread weak references in globals.c Linking executables will fail on systems with glibc < 2.34 without declaring these symbols as weak references. In commit c19771c1f13de9196f98260d142d8c8672eb5733 these references were moved to globals.c from threads.c, but the `#pragma weak` declarations were lost in the process. Also removing unneeded weak declarations from threads.c. --- globals.c | 5 +++++ threads.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/globals.c b/globals.c index a786a4b9e..fe2401384 100644 --- a/globals.c +++ b/globals.c @@ -118,6 +118,11 @@ static XML_THREAD_LOCAL xmlGlobalState globalState; defined(__GLIBC__) && \ __GLIBC__ * 100 + __GLIBC_MINOR__ < 234 +#pragma weak pthread_getspecific +#pragma weak pthread_setspecific +#pragma weak pthread_key_create +#pragma weak pthread_key_delete + #define XML_PTHREAD_WEAK static int libxml_is_threaded = -1; diff --git a/threads.c b/threads.c index 3e8ef2fe4..461f4a514 100644 --- a/threads.c +++ b/threads.c @@ -78,8 +78,6 @@ #pragma weak pthread_cond_wait #pragma weak pthread_equal #pragma weak pthread_self -#pragma weak pthread_key_create -#pragma weak pthread_key_delete #pragma weak pthread_cond_signal #define XML_PTHREAD_WEAK From 62d318f86c1af39e10d31ff68f91e276d88d1316 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 18 Nov 2023 14:21:45 -0500 Subject: [PATCH 004/504] fix: more pthread weak references in globals.c --- globals.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/globals.c b/globals.c index fe2401384..57b710a47 100644 --- a/globals.c +++ b/globals.c @@ -122,6 +122,8 @@ static XML_THREAD_LOCAL xmlGlobalState globalState; #pragma weak pthread_setspecific #pragma weak pthread_key_create #pragma weak pthread_key_delete +#pragma weak pthread_equal +#pragma weak pthread_self #define XML_PTHREAD_WEAK @@ -571,7 +573,13 @@ void xmlInitGlobalsInternal(void) { (pthread_getspecific != NULL) && (pthread_setspecific != NULL) && (pthread_key_create != NULL) && - (pthread_key_delete != NULL); + (pthread_key_delete != NULL) && + /* + * pthread_equal can be inline, resuting in -Waddress warnings. + * Let's assume it's available if all the other functions are. + */ + /* (pthread_equal != NULL) && */ + (pthread_self != NULL); if (libxml_is_threaded == 0) return; #endif /* XML_PTHREAD_WEAK */ From 272cb2231341f717b6bc676d647b2973e853af19 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 Nov 2023 14:22:18 +0100 Subject: [PATCH 005/504] dict: Fix '__thread' before 'static' When used with extern or static, __thread must appear immediately after the other storage class specifier. Fixes #621. --- dict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dict.c b/dict.c index df49b5b5a..d7156ed3d 100644 --- a/dict.c +++ b/dict.c @@ -909,8 +909,8 @@ static xmlMutex xmlRngMutex; static unsigned globalRngState[2]; #ifdef XML_THREAD_LOCAL -XML_THREAD_LOCAL static int localRngInitialized = 0; -XML_THREAD_LOCAL static unsigned localRngState[2]; +static XML_THREAD_LOCAL int localRngInitialized = 0; +static XML_THREAD_LOCAL unsigned localRngState[2]; #endif ATTRIBUTE_NO_SANITIZE_INTEGER From aca37d8c77cd66cc628f1b748b8f55434a4168aa Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 Nov 2023 15:20:37 +0100 Subject: [PATCH 006/504] parser: Only enable SAX2 if there are SAX2 element handlers This reverts part of commit 235b15a5 for backward compatibility and adds some comments trying to clarify the whole mess. Fixes #623. --- include/libxml/parser.h | 21 ++++++++++++++++++++- parser.c | 9 ++++++++- testrecurse.c | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/libxml/parser.h b/include/libxml/parser.h index a848dccf1..5fa5f6c9f 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -745,6 +745,19 @@ struct _xmlSAXHandler { setDocumentLocatorSAXFunc setDocumentLocator; startDocumentSAXFunc startDocument; endDocumentSAXFunc endDocument; + /* + * `startElement` and `endElement` are only used by the legacy SAX1 + * interface and should not be used in new software. If you really + * have to enable SAX1, the preferred way is set the `initialized` + * member to 1 instead of XML_SAX2_MAGIC. + * + * For backward compatibility, it's also possible to set the + * `startElementNs` and `endElementNs` handlers to NULL. + * + * You can also set the XML_PARSE_SAX1 parser option, but versions + * older than 2.12.0 will probably crash if this option is provided + * together with custom SAX callbacks. + */ startElementSAXFunc startElement; endElementSAXFunc endElement; referenceSAXFunc reference; @@ -758,8 +771,14 @@ struct _xmlSAXHandler { getParameterEntitySAXFunc getParameterEntity; cdataBlockSAXFunc cdataBlock; externalSubsetSAXFunc externalSubset; + /* + * `initialized` should always be set to XML_SAX2_MAGIC to enable the + * modern SAX2 interface. + */ unsigned int initialized; - /* The following fields are extensions available only on version 2 */ + /* + * The following members are only used by the SAX2 interface. + */ void *_private; startElementNsSAX2Func startElementNs; endElementNsSAX2Func endElementNs; diff --git a/parser.c b/parser.c index e291049a4..6b0eb4213 100644 --- a/parser.c +++ b/parser.c @@ -863,7 +863,14 @@ xmlDetectSAX2(xmlParserCtxtPtr ctxt) { if (ctxt == NULL) return; sax = ctxt->sax; #ifdef LIBXML_SAX1_ENABLED - if ((sax) && (sax->initialized == XML_SAX2_MAGIC)) + /* + * Only enable SAX2 if there SAX2 element handlers, except when there + * are no element handlers at all. + */ + if ((sax) && (sax->initialized == XML_SAX2_MAGIC) && + ((sax->startElementNs != NULL) || + (sax->endElementNs != NULL) || + ((sax->startElement == NULL) && (sax->endElement == NULL)))) ctxt->sax2 = 1; #else ctxt->sax2 = 1; diff --git a/testrecurse.c b/testrecurse.c index d76d80acc..63b6bc4d7 100644 --- a/testrecurse.c +++ b/testrecurse.c @@ -646,6 +646,8 @@ static void initSAX(xmlParserCtxtPtr ctxt) { ctxt->sax->startElementNs = NULL; ctxt->sax->endElementNs = NULL; + ctxt->sax->startElement = NULL; + ctxt->sax->endElement = NULL; ctxt->sax->characters = NULL; ctxt->sax->cdataBlock = NULL; ctxt->sax->ignorableWhitespace = NULL; From a2b5c90a442295d2b75ae60af854b3c4a43aa0ff Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 Nov 2023 14:35:54 +0100 Subject: [PATCH 007/504] hash: Fix deletion of entries during scan Functions like xmlCleanSpecialAttr scan a hash table and possibly delete entries in the callback. xmlHashScanFull must detect such deletions and rescan the entry. This regressed when rewriting the hash table code in 4a513d56. Fixes #626. --- hash.c | 76 ++++++++++++++++++++++++++++------ result/issue626.xml | 14 +++++++ result/issue626.xml.rde | 12 ++++++ result/issue626.xml.rdr | 12 ++++++ result/issue626.xml.sax | 23 ++++++++++ result/issue626.xml.sax2 | 23 ++++++++++ result/noent/issue626.xml | 14 +++++++ result/noent/issue626.xml.sax2 | 23 ++++++++++ test/issue626.xml | 13 ++++++ 9 files changed, 198 insertions(+), 12 deletions(-) create mode 100644 result/issue626.xml create mode 100644 result/issue626.xml.rde create mode 100644 result/issue626.xml.rdr create mode 100644 result/issue626.xml.sax create mode 100644 result/issue626.xml.sax2 create mode 100644 result/noent/issue626.xml create mode 100644 result/noent/issue626.xml.sax2 create mode 100644 test/issue626.xml diff --git a/hash.c b/hash.c index f3ec63968..38341d782 100644 --- a/hash.c +++ b/hash.c @@ -913,15 +913,42 @@ xmlHashScan(xmlHashTablePtr hash, xmlHashScanner scan, void *data) { void xmlHashScanFull(xmlHashTablePtr hash, xmlHashScannerFull scan, void *data) { const xmlHashEntry *entry, *end; + xmlHashEntry old; + unsigned i; if ((hash == NULL) || (hash->size == 0) || (scan == NULL)) return; + /* + * We must handle the case that a scanned entry is removed when executing + * the callback (xmlCleanSpecialAttr and possibly other places). + * + * Find the start of a probe sequence to avoid scanning entries twice if + * a deletion happens. + */ + entry = hash->table; end = &hash->table[hash->size]; + while (entry->hashValue != 0) { + if (++entry >= end) + entry = hash->table; + } - for (entry = hash->table; entry < end; entry++) { - if ((entry->hashValue != 0) && (entry->payload != NULL)) - scan(entry->payload, data, entry->key, entry->key2, entry->key3); + for (i = 0; i < hash->size; i++) { + if ((entry->hashValue != 0) && (entry->payload != NULL)) { + /* + * Make sure to rescan after a possible deletion. + */ + do { + old = *entry; + scan(entry->payload, data, entry->key, entry->key2, entry->key3); + } while ((entry->hashValue != 0) && + (entry->payload != NULL) && + ((entry->key != old.key) || + (entry->key2 != old.key2) || + (entry->key3 != old.key3))); + } + if (++entry >= end) + entry = hash->table; } } @@ -966,22 +993,47 @@ xmlHashScanFull3(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, const xmlChar *key3, xmlHashScannerFull scan, void *data) { const xmlHashEntry *entry, *end; + xmlHashEntry old; + unsigned i; if ((hash == NULL) || (hash->size == 0) || (scan == NULL)) return; + /* + * We must handle the case that a scanned entry is removed when executing + * the callback (xmlCleanSpecialAttr and possibly other places). + * + * Find the start of a probe sequence to avoid scanning entries twice if + * a deletion happens. + */ + entry = hash->table; end = &hash->table[hash->size]; + while (entry->hashValue != 0) { + if (++entry >= end) + entry = hash->table; + } - for (entry = hash->table; entry < end; entry++) { - if (entry->hashValue == 0) - continue; - if (((key == NULL) || - (strcmp((const char *) key, (const char *) entry->key) == 0)) && - ((key2 == NULL) || (xmlFastStrEqual(key2, entry->key2))) && - ((key3 == NULL) || (xmlFastStrEqual(key3, entry->key3))) && - (entry->payload != NULL)) { - scan(entry->payload, data, entry->key, entry->key2, entry->key3); + for (i = 0; i < hash->size; i++) { + if ((entry->hashValue != 0) && (entry->payload != NULL)) { + /* + * Make sure to rescan after a possible deletion. + */ + do { + if (((key != NULL) && (strcmp((const char *) key, + (const char *) entry->key) != 0)) || + ((key2 != NULL) && (!xmlFastStrEqual(key2, entry->key2))) || + ((key3 != NULL) && (!xmlFastStrEqual(key3, entry->key3)))) + break; + old = *entry; + scan(entry->payload, data, entry->key, entry->key2, entry->key3); + } while ((entry->hashValue != 0) && + (entry->payload != NULL) && + ((entry->key != old.key) || + (entry->key2 != old.key2) || + (entry->key3 != old.key3))); } + if (++entry >= end) + entry = hash->table; } } diff --git a/result/issue626.xml b/result/issue626.xml new file mode 100644 index 000000000..001b3d9cc --- /dev/null +++ b/result/issue626.xml @@ -0,0 +1,14 @@ + + + + + + + +]> + + + + diff --git a/result/issue626.xml.rde b/result/issue626.xml.rde new file mode 100644 index 000000000..a488238ae --- /dev/null +++ b/result/issue626.xml.rde @@ -0,0 +1,12 @@ +0 10 doc 0 0 +0 1 doc 0 0 +1 14 #text 0 1 + +1 8 #comment 0 1 This tests whether xmlCleanSpecialAttr works. The attribute values + must not be normalized. +1 14 #text 0 1 + +1 1 e 1 0 +1 14 #text 0 1 + +0 15 doc 0 0 diff --git a/result/issue626.xml.rdr b/result/issue626.xml.rdr new file mode 100644 index 000000000..a488238ae --- /dev/null +++ b/result/issue626.xml.rdr @@ -0,0 +1,12 @@ +0 10 doc 0 0 +0 1 doc 0 0 +1 14 #text 0 1 + +1 8 #comment 0 1 This tests whether xmlCleanSpecialAttr works. The attribute values + must not be normalized. +1 14 #text 0 1 + +1 1 e 1 0 +1 14 #text 0 1 + +0 15 doc 0 0 diff --git a/result/issue626.xml.sax b/result/issue626.xml.sax new file mode 100644 index 000000000..8e6b59b5d --- /dev/null +++ b/result/issue626.xml.sax @@ -0,0 +1,23 @@ +SAX.setDocumentLocator() +SAX.startDocument() +SAX.internalSubset(doc, , ) +SAX.attributeDecl(e, a1, 1, 3, NULL, ...) +SAX.attributeDecl(e, a2, 1, 3, NULL, ...) +SAX.attributeDecl(e, a3, 1, 3, NULL, ...) +SAX.attributeDecl(e, a4, 1, 3, NULL, ...) +SAX.attributeDecl(e, a5, 1, 3, NULL, ...) +SAX.attributeDecl(e, a6, 1, 3, NULL, ...) +SAX.externalSubset(doc, , ) +SAX.startElement(doc) +SAX.characters( + , 5) +SAX.comment( This tests whether xmlCleanSpecialAttr works. The attribute values + must not be normalized. ) +SAX.characters( + , 5) +SAX.startElement(e, a1=' x x ', a2=' x x ', a3=' x x ', a4=' x x ', a5=' x x ', a6=' x x ') +SAX.endElement(e) +SAX.characters( +, 1) +SAX.endElement(doc) +SAX.endDocument() diff --git a/result/issue626.xml.sax2 b/result/issue626.xml.sax2 new file mode 100644 index 000000000..edc2c1f91 --- /dev/null +++ b/result/issue626.xml.sax2 @@ -0,0 +1,23 @@ +SAX.setDocumentLocator() +SAX.startDocument() +SAX.internalSubset(doc, , ) +SAX.attributeDecl(e, a1, 1, 3, NULL, ...) +SAX.attributeDecl(e, a2, 1, 3, NULL, ...) +SAX.attributeDecl(e, a3, 1, 3, NULL, ...) +SAX.attributeDecl(e, a4, 1, 3, NULL, ...) +SAX.attributeDecl(e, a5, 1, 3, NULL, ...) +SAX.attributeDecl(e, a6, 1, 3, NULL, ...) +SAX.externalSubset(doc, , ) +SAX.startElementNs(doc, NULL, NULL, 0, 0, 0) +SAX.characters( + , 5) +SAX.comment( This tests whether xmlCleanSpecialAttr works. The attribute values + must not be normalized. ) +SAX.characters( + , 5) +SAX.startElementNs(e, NULL, NULL, 0, 6, 0, a1=' x ...', 6, a2=' x ...', 6, a3=' x ...', 6, a4=' x ...', 6, a5=' x ...', 6, a6=' x ...', 6) +SAX.endElementNs(e, NULL, NULL) +SAX.characters( +, 1) +SAX.endElementNs(doc, NULL, NULL) +SAX.endDocument() diff --git a/result/noent/issue626.xml b/result/noent/issue626.xml new file mode 100644 index 000000000..001b3d9cc --- /dev/null +++ b/result/noent/issue626.xml @@ -0,0 +1,14 @@ + + + + + + + +]> + + + + diff --git a/result/noent/issue626.xml.sax2 b/result/noent/issue626.xml.sax2 new file mode 100644 index 000000000..edc2c1f91 --- /dev/null +++ b/result/noent/issue626.xml.sax2 @@ -0,0 +1,23 @@ +SAX.setDocumentLocator() +SAX.startDocument() +SAX.internalSubset(doc, , ) +SAX.attributeDecl(e, a1, 1, 3, NULL, ...) +SAX.attributeDecl(e, a2, 1, 3, NULL, ...) +SAX.attributeDecl(e, a3, 1, 3, NULL, ...) +SAX.attributeDecl(e, a4, 1, 3, NULL, ...) +SAX.attributeDecl(e, a5, 1, 3, NULL, ...) +SAX.attributeDecl(e, a6, 1, 3, NULL, ...) +SAX.externalSubset(doc, , ) +SAX.startElementNs(doc, NULL, NULL, 0, 0, 0) +SAX.characters( + , 5) +SAX.comment( This tests whether xmlCleanSpecialAttr works. The attribute values + must not be normalized. ) +SAX.characters( + , 5) +SAX.startElementNs(e, NULL, NULL, 0, 6, 0, a1=' x ...', 6, a2=' x ...', 6, a3=' x ...', 6, a4=' x ...', 6, a5=' x ...', 6, a6=' x ...', 6) +SAX.endElementNs(e, NULL, NULL) +SAX.characters( +, 1) +SAX.endElementNs(doc, NULL, NULL) +SAX.endDocument() diff --git a/test/issue626.xml b/test/issue626.xml new file mode 100644 index 000000000..5b0f6832a --- /dev/null +++ b/test/issue626.xml @@ -0,0 +1,13 @@ + + + + + + +]> + + + + From f3c24112d309384e3462a6226eb13dce3f19a692 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 22 Nov 2023 02:00:00 +0100 Subject: [PATCH 008/504] autotools: Stop checking for snprintf This works around a bug when cross-compiling to 32-bit MinGW: https://sourceforge.net/p/mingw-w64/bugs/935/ This means that we don't fall back to the bundled Trio library if snprintf couldn't be detected. Trio support is completely untested, most likely broken and will be removed soon. Fixes #625. --- configure.ac | 5 ----- 1 file changed, 5 deletions(-) diff --git a/configure.ac b/configure.ac index aca3c56e3..0dd507207 100644 --- a/configure.ac +++ b/configure.ac @@ -309,11 +309,6 @@ dnl Checking types dnl AC_TYPE_UINT32_T -dnl -dnl Checking libraries -dnl -AC_CHECK_FUNCS(snprintf vsnprintf,, NEED_TRIO=1) - dnl Checks for library functions. AC_CHECK_FUNCS([gettimeofday ftime stat isascii mmap munmap]) From f8394adf1483e4c5b1a24ccaa2f568cfccab32db Mon Sep 17 00:00:00 2001 From: makise-homura Date: Wed, 8 Nov 2023 23:52:27 +0300 Subject: [PATCH 009/504] Avoid using no_sanitize attribute on EDG even if compiler shows as GCC --- libxml.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml.h b/libxml.h index 2f72e0ac1..8d6b43a34 100644 --- a/libxml.h +++ b/libxml.h @@ -53,7 +53,7 @@ #endif #if defined(__clang__) || \ - (defined(__GNUC__) && (__GNUC__ >= 8)) + (defined(__GNUC__) && (__GNUC__ >= 8) && !defined(__EDG__)) #define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg))) #else #define ATTRIBUTE_NO_SANITIZE(arg) From 595c19a5923ad46b19d0579a28c71b8a2be8c019 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Wed, 8 Nov 2023 23:59:56 +0300 Subject: [PATCH 010/504] Avoid EDG -Wtype-limits warnings on unsigned comparisons with zero by conversion from unsigned int to int --- xmlschemastypes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmlschemastypes.c b/xmlschemastypes.c index de95d9407..c6624a17a 100644 --- a/xmlschemastypes.c +++ b/xmlschemastypes.c @@ -1273,7 +1273,7 @@ static const unsigned int daysInMonthLeap[12] = ((dt)->hour == 24 && (dt)->min == 0 && (dt)->sec == 0) #define VALID_TIME(dt) \ - (((VALID_HOUR(dt->hour) && VALID_MIN(dt->min) && \ + (((VALID_HOUR((int)dt->hour) && VALID_MIN((int)dt->min) && \ VALID_SEC(dt->sec)) || VALID_END_OF_DAY(dt)) && \ VALID_TZO(dt->tzo)) From c1e9f761e0d8f7a3a86757d9a71df07376b51ca9 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Thu, 9 Nov 2023 01:44:09 +0300 Subject: [PATCH 011/504] Avoid EDG -Woverflow warnings on truncating conversions by manually truncating operand --- dict.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dict.c b/dict.c index d7156ed3d..a0d311a2d 100644 --- a/dict.c +++ b/dict.c @@ -923,9 +923,9 @@ xmlInitRandom(void) { /* TODO: Get seed values from system PRNG */ globalRngState[0] = (unsigned) time(NULL) ^ - HASH_ROL((unsigned) (size_t) &xmlInitRandom, 8); - globalRngState[1] = HASH_ROL((unsigned) (size_t) &xmlRngMutex, 16) ^ - HASH_ROL((unsigned) (size_t) &var, 24); + HASH_ROL((unsigned) ((size_t) &xmlInitRandom & 0xFFFFFFFF), 8); + globalRngState[1] = HASH_ROL((unsigned) ((size_t) &xmlRngMutex & 0xFFFFFFFF), 16) ^ + HASH_ROL((unsigned) ((size_t) &var & 0xFFFFFFFF), 24); } void From 6bc86405d1474f689bd2e4b94d5271b7277690e1 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Thu, 9 Nov 2023 02:04:15 +0300 Subject: [PATCH 012/504] Avoid EDG deprecation warnings for LCC compiler --- include/libxml/xmlversion.h.in | 6 +++++- python/libxml_wrap.h | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/libxml/xmlversion.h.in b/include/libxml/xmlversion.h.in index 7c72533f7..bdc27087c 100644 --- a/include/libxml/xmlversion.h.in +++ b/include/libxml/xmlversion.h.in @@ -448,7 +448,11 @@ XMLPUBFUN void xmlCheckVersion(int version); # endif #endif -#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) +#if defined(__LCC__) + #define XML_IGNORE_FPTR_CAST_WARNINGS + #define XML_POP_WARNINGS \ + _Pragma("diag_default 1215") +#elif defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) #if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 800) #define XML_IGNORE_FPTR_CAST_WARNINGS \ _Pragma("GCC diagnostic push") \ diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h index f9e1f8903..d13c59643 100644 --- a/python/libxml_wrap.h +++ b/python/libxml_wrap.h @@ -65,7 +65,10 @@ /* * Macros to ignore deprecation warnings */ -#if defined(__clang__) || \ +#if defined(__LCC__) +#define XML_IGNORE_DEPRECATION_WARNINGS \ + _Pragma("diag_suppress 1215") +#elif defined(__clang__) || \ (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) #define XML_IGNORE_DEPRECATION_WARNINGS \ _Pragma("GCC diagnostic push") \ From 873c17116598cfc8fc2eb3a6fe7b9ac43306cc53 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Wed, 22 Nov 2023 08:23:00 +0300 Subject: [PATCH 013/504] Avoid EDG -Wignored-qualifiers warnings on wrong 'const *' to '* const' conversions --- c14n.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/c14n.c b/c14n.c index 3d2e14449..ae7304413 100644 --- a/c14n.c +++ b/c14n.c @@ -513,8 +513,8 @@ xmlC14NIsXmlNs(xmlNsPtr ns) static int xmlC14NNsCompare(const void *data1, const void *data2) { - const xmlNsPtr ns1 = (const xmlNsPtr) data1; - const xmlNsPtr ns2 = (const xmlNsPtr) data2; + const xmlNs *ns1 = data1; + const xmlNs *ns2 = data2; if (ns1 == ns2) return (0); if (ns1 == NULL) @@ -536,7 +536,7 @@ xmlC14NNsCompare(const void *data1, const void *data2) * Returns 1 on success or 0 on fail. */ static int -xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx) +xmlC14NPrintNamespaces(const xmlNs *ns, xmlC14NCtxPtr ctx) { if ((ns == NULL) || (ctx == NULL)) { @@ -561,7 +561,7 @@ xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx) static int xmlC14NPrintNamespacesWalker(const void *ns, void *ctx) { - return xmlC14NPrintNamespaces((const xmlNsPtr) ns, (xmlC14NCtxPtr) ctx); + return xmlC14NPrintNamespaces(ns, ctx); } /** @@ -886,8 +886,8 @@ xmlC14NIsXmlAttr(xmlAttrPtr attr) static int xmlC14NAttrsCompare(const void *data1, const void *data2) { - const xmlAttrPtr attr1 = (const xmlAttrPtr) data1; - const xmlAttrPtr attr2 = (const xmlAttrPtr) data2; + const xmlAttr *attr1 = data1; + const xmlAttr *attr2 = data2; int ret = 0; /* @@ -940,7 +940,7 @@ xmlC14NAttrsCompare(const void *data1, const void *data2) static int xmlC14NPrintAttrs(const void *data, void *user) { - const xmlAttrPtr attr = (const xmlAttrPtr) data; + const xmlAttr *attr = data; xmlC14NCtxPtr ctx = (xmlC14NCtxPtr) user; xmlChar *value; xmlChar *buffer; From a3971573b47215c550a8b85f020fd2216e6edcde Mon Sep 17 00:00:00 2001 From: makise-homura Date: Wed, 22 Nov 2023 08:25:27 +0300 Subject: [PATCH 014/504] Don't let gentest.py cast types to 'const somethingPtr' to avoid -Wignored-qualifiers --- gentest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gentest.py b/gentest.py index 16c0e3791..ac016e80e 100755 --- a/gentest.py +++ b/gentest.py @@ -825,7 +825,7 @@ def generate_test(module, node): test.write(", ") else: need = 1 - if rtype != crtype: + if rtype != crtype and (rtype[-3:] != "Ptr" or rtype[:6] != "const "): test.write("(%s)" % rtype) test.write("%s" % nam); test.write(");\n") @@ -841,7 +841,7 @@ def generate_test(module, node): test.write(", ") else: need = 1 - if rtype != crtype: + if rtype != crtype and (rtype[-3:] != "Ptr" or rtype[:6] != "const "): test.write("(%s)" % rtype) test.write("%s" % nam) test.write(");\n") @@ -859,7 +859,7 @@ def generate_test(module, node): # a better, more generic way to do this! if info.find('destroy') == -1: test.write(" des_%s(n_%s, " % (type, nam)) - if rtype != crtype: + if rtype != crtype and (rtype[-3:] != "Ptr" or rtype[:6] != "const "): test.write("(%s)" % rtype) test.write("%s, %d);\n" % (nam, i)) i = i + 1; From 19b9c59b6106f816f000bcf83c8e6845cdce56ce Mon Sep 17 00:00:00 2001 From: makise-homura Date: Wed, 22 Nov 2023 08:25:56 +0300 Subject: [PATCH 015/504] Regenerate testapi.c --- testapi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/testapi.c b/testapi.c index 0a0aadffe..edebca6bf 100644 --- a/testapi.c +++ b/testapi.c @@ -2320,10 +2320,10 @@ test_htmlNodeStatus(void) { node = gen_const_htmlNodePtr(n_node, 0); legacy = gen_int(n_legacy, 1); - ret_val = htmlNodeStatus((const htmlNodePtr)node, legacy); + ret_val = htmlNodeStatus(node, legacy); desret_htmlStatus(ret_val); call_tests++; - des_const_htmlNodePtr(n_node, (const htmlNodePtr)node, 0); + des_const_htmlNodePtr(n_node, node, 0); des_int(n_legacy, legacy, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -10886,11 +10886,11 @@ test_xmlListCopy(void) { cur = gen_xmlListPtr(n_cur, 0); old = gen_const_xmlListPtr(n_old, 1); - ret_val = xmlListCopy(cur, (const xmlListPtr)old); + ret_val = xmlListCopy(cur, old); desret_int(ret_val); call_tests++; des_xmlListPtr(n_cur, cur, 0); - des_const_xmlListPtr(n_old, (const xmlListPtr)old, 1); + des_const_xmlListPtr(n_old, old, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlListCopy", @@ -13645,10 +13645,10 @@ test_xmlParserAddNodeInfo(void) { ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); info = gen_const_xmlParserNodeInfoPtr(n_info, 1); - xmlParserAddNodeInfo(ctxt, (const xmlParserNodeInfoPtr)info); + xmlParserAddNodeInfo(ctxt, info); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlParserNodeInfoPtr(n_info, (const xmlParserNodeInfoPtr)info, 1); + des_const_xmlParserNodeInfoPtr(n_info, info, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParserAddNodeInfo", @@ -13691,11 +13691,11 @@ test_xmlParserFindNodeInfo(void) { ctx = gen_const_xmlParserCtxtPtr(n_ctx, 0); node = gen_const_xmlNodePtr(n_node, 1); - ret_val = xmlParserFindNodeInfo((const xmlParserCtxtPtr)ctx, (const xmlNodePtr)node); + ret_val = xmlParserFindNodeInfo(ctx, node); desret_const_xmlParserNodeInfo_ptr(ret_val); call_tests++; - des_const_xmlParserCtxtPtr(n_ctx, (const xmlParserCtxtPtr)ctx, 0); - des_const_xmlNodePtr(n_node, (const xmlNodePtr)node, 1); + des_const_xmlParserCtxtPtr(n_ctx, ctx, 0); + des_const_xmlNodePtr(n_node, node, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParserFindNodeInfo", @@ -13734,11 +13734,11 @@ test_xmlParserFindNodeInfoIndex(void) { seq = gen_const_xmlParserNodeInfoSeqPtr(n_seq, 0); node = gen_const_xmlNodePtr(n_node, 1); - ret_val = xmlParserFindNodeInfoIndex((const xmlParserNodeInfoSeqPtr)seq, (const xmlNodePtr)node); + ret_val = xmlParserFindNodeInfoIndex(seq, node); desret_unsigned_long(ret_val); call_tests++; - des_const_xmlParserNodeInfoSeqPtr(n_seq, (const xmlParserNodeInfoSeqPtr)seq, 0); - des_const_xmlNodePtr(n_node, (const xmlNodePtr)node, 1); + des_const_xmlParserNodeInfoSeqPtr(n_seq, seq, 0); + des_const_xmlNodePtr(n_node, node, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParserFindNodeInfoIndex", From ff6c31886213d859a1083686cca7ae5c3ba8e9c8 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 23 Nov 2023 15:22:59 +0100 Subject: [PATCH 016/504] include: Remove useless 'const' from function arguments --- HTMLparser.c | 2 +- include/libxml/HTMLparser.h | 2 +- include/libxml/list.h | 4 ++-- include/libxml/parser.h | 10 +++++----- list.c | 4 ++-- parserInternals.c | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/HTMLparser.c b/HTMLparser.c index fa1fe380a..11ad94430 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -6307,7 +6307,7 @@ htmlAttrAllowed(const htmlElemDesc* elt, const xmlChar* attr, int legacy) { * for other nodes, HTML_NA (no checks performed) */ htmlStatus -htmlNodeStatus(const htmlNodePtr node, int legacy) { +htmlNodeStatus(htmlNodePtr node, int legacy) { if ( ! node ) return HTML_INVALID ; diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h index e16d77492..8137c1902 100644 --- a/include/libxml/HTMLparser.h +++ b/include/libxml/HTMLparser.h @@ -300,7 +300,7 @@ typedef enum { XMLPUBFUN htmlStatus htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ; XMLPUBFUN int htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ; XMLPUBFUN htmlStatus htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ; -XMLPUBFUN htmlStatus htmlNodeStatus(const htmlNodePtr, int) ; +XMLPUBFUN htmlStatus htmlNodeStatus(htmlNodePtr, int) ; /** * htmlDefaultSubelement: * @elt: HTML element diff --git a/include/libxml/list.h b/include/libxml/list.h index 5eab8f59d..1fa76aff0 100644 --- a/include/libxml/list.h +++ b/include/libxml/list.h @@ -119,10 +119,10 @@ XMLPUBFUN void xmlListMerge (xmlListPtr l1, xmlListPtr l2); XMLPUBFUN xmlListPtr - xmlListDup (const xmlListPtr old); + xmlListDup (xmlListPtr old); XMLPUBFUN int xmlListCopy (xmlListPtr cur, - const xmlListPtr old); + xmlListPtr old); /* Link operators */ XMLPUBFUN void * xmlLinkGetData (xmlLinkPtr lk); diff --git a/include/libxml/parser.h b/include/libxml/parser.h index 5fa5f6c9f..f7e011a99 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -1162,18 +1162,18 @@ XMLPUBFUN xmlParserInputPtr * Node infos. */ XMLPUBFUN const xmlParserNodeInfo* - xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, - const xmlNodePtr node); + xmlParserFindNodeInfo (xmlParserCtxtPtr ctxt, + xmlNodePtr node); XMLPUBFUN void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); XMLPUBFUN void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); XMLPUBFUN unsigned long - xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, - const xmlNodePtr node); + xmlParserFindNodeInfoIndex(xmlParserNodeInfoSeqPtr seq, + xmlNodePtr node); XMLPUBFUN void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, - const xmlParserNodeInfoPtr info); + xmlParserNodeInfoPtr info); /* * External entities handling actually implemented in xmlIO. diff --git a/list.c b/list.c index 4927a2630..3eaf67f9d 100644 --- a/list.c +++ b/list.c @@ -729,7 +729,7 @@ xmlListMerge(xmlListPtr l1, xmlListPtr l2) * Returns a new copy of the list or NULL in case of error */ xmlListPtr -xmlListDup(const xmlListPtr old) +xmlListDup(xmlListPtr old) { xmlListPtr cur; @@ -758,7 +758,7 @@ xmlListDup(const xmlListPtr old) * Returns 0 in case of success 1 in case of error */ int -xmlListCopy(xmlListPtr cur, const xmlListPtr old) +xmlListCopy(xmlListPtr cur, xmlListPtr old) { /* Walk the old tree and insert the data into the new one */ xmlLinkPtr lk; diff --git a/parserInternals.c b/parserInternals.c index 77b5a00b1..29deebe42 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -2120,7 +2120,7 @@ xmlClearParserCtxt(xmlParserCtxtPtr ctxt) * Returns an xmlParserNodeInfo block pointer or NULL */ const xmlParserNodeInfo * -xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx, const xmlNodePtr node) +xmlParserFindNodeInfo(xmlParserCtxtPtr ctx, xmlNodePtr node) { unsigned long pos; @@ -2186,8 +2186,8 @@ xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq) * Returns a long indicating the position of the record */ unsigned long -xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, - const xmlNodePtr node) +xmlParserFindNodeInfoIndex(xmlParserNodeInfoSeqPtr seq, + xmlNodePtr node) { unsigned long upper, lower, middle; int found = 0; @@ -2228,7 +2228,7 @@ xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, */ void xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt, - const xmlParserNodeInfoPtr info) + xmlParserNodeInfoPtr info) { unsigned long pos; From e42faa6d78c782a86fdb983bb21bb638bca6cd7a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 23 Nov 2023 15:25:04 +0100 Subject: [PATCH 017/504] tests: Remove special handling of const pointers in gentest.py --- gentest.py | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/gentest.py b/gentest.py index ac016e80e..79025f839 100755 --- a/gentest.py +++ b/gentest.py @@ -423,11 +423,6 @@ def generate_param_type(name, rtype): return if name[-3:] == 'Ptr' or name[-4:] == '_ptr': - if rtype[0:6] == 'const ': - crtype = rtype[6:] - else: - crtype = rtype - define = 0 if module in modules_defines: test.write("#ifdef %s\n" % (modules_defines[module])) @@ -700,12 +695,7 @@ def generate_test(module, node): if is_known_param_type(type) == 0: add_missing_type(type, name); no_gen = 1 - if (type[-3:] == 'Ptr' or type[-4:] == '_ptr') and \ - rtype[0:6] == 'const ': - crtype = rtype[6:] - else: - crtype = rtype - t_args.append((nam, type, rtype, crtype, info)) + t_args.append((nam, type, rtype, info)) try: rets = node.xpathEval("return") @@ -726,7 +716,7 @@ def generate_test(module, node): if no_gen == 0: for t_arg in t_args: - (nam, type, rtype, crtype, info) = t_arg + (nam, type, rtype, info) = t_arg generate_param_type(type, rtype) test.write(""" @@ -770,15 +760,15 @@ def generate_test(module, node): # Declare the arguments for arg in t_args: - (nam, type, rtype, crtype, info) = arg; + (nam, type, rtype, info) = arg; # add declaration - test.write(" %s %s; /* %s */\n" % (crtype, nam, info)) + test.write(" %s %s; /* %s */\n" % (rtype, nam, info)) test.write(" int n_%s;\n" % (nam)) test.write("\n") # Cascade loop on of each argument list of values for arg in t_args: - (nam, type, rtype, crtype, info) = arg; + (nam, type, rtype, info) = arg; # test.write(" for (n_%s = 0;n_%s < gen_nb_%s;n_%s++) {\n" % ( nam, nam, type, nam)) @@ -790,7 +780,7 @@ def generate_test(module, node): # prepare the call i = 0; for arg in t_args: - (nam, type, rtype, crtype, info) = arg; + (nam, type, rtype, info) = arg; # test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) i = i + 1; @@ -798,7 +788,7 @@ def generate_test(module, node): # add checks to avoid out-of-bounds array access i = 0; for arg in t_args: - (nam, type, rtype, crtype, info) = arg; + (nam, type, rtype, info) = arg; # assume that "size", "len", and "start" parameters apply to either # the nearest preceding or following char pointer if type == "int" and (nam == "size" or nam == "len" or nam == "start"): @@ -820,13 +810,11 @@ def generate_test(module, node): test.write("\n ret_val = %s(" % (name)) need = 0 for arg in t_args: - (nam, type, rtype, crtype, info) = arg + (nam, type, rtype, info) = arg if need: test.write(", ") else: need = 1 - if rtype != crtype and (rtype[-3:] != "Ptr" or rtype[:6] != "const "): - test.write("(%s)" % rtype) test.write("%s" % nam); test.write(");\n") if name in extra_post_call: @@ -836,13 +824,11 @@ def generate_test(module, node): test.write("\n %s(" % (name)); need = 0; for arg in t_args: - (nam, type, rtype, crtype, info) = arg; + (nam, type, rtype, info) = arg; if need: test.write(", ") else: need = 1 - if rtype != crtype and (rtype[-3:] != "Ptr" or rtype[:6] != "const "): - test.write("(%s)" % rtype) test.write("%s" % nam) test.write(");\n") if name in extra_post_call: @@ -853,14 +839,12 @@ def generate_test(module, node): # Free the arguments i = 0; for arg in t_args: - (nam, type, rtype, crtype, info) = arg; + (nam, type, rtype, info) = arg; # This is a hack to prevent generating a destructor for the # 'input' argument in xmlTextReaderSetup. There should be # a better, more generic way to do this! if info.find('destroy') == -1: test.write(" des_%s(n_%s, " % (type, nam)) - if rtype != crtype and (rtype[-3:] != "Ptr" or rtype[:6] != "const "): - test.write("(%s)" % rtype) test.write("%s, %d);\n" % (nam, i)) i = i + 1; @@ -873,7 +857,7 @@ def generate_test(module, node): \t test_ret++; """ % (name)); for arg in t_args: - (nam, type, rtype, crtype, info) = arg; + (nam, type, rtype, info) = arg; test.write(""" printf(" %%d", n_%s);\n""" % (nam)) test.write(""" printf("\\n");\n""") test.write(" }\n") From f5d4d33bfa2ea361275ee8d9c20767f014b28605 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 23 Nov 2023 15:25:54 +0100 Subject: [PATCH 018/504] tests: Regenerate testapi.c --- doc/libxml2-api.xml | 36 +- testapi.c | 3224 +++++++++++++++++++++---------------------- 2 files changed, 1620 insertions(+), 1640 deletions(-) diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml index 1dee142cb..8b2e93794 100644 --- a/doc/libxml2-api.xml +++ b/doc/libxml2-api.xml @@ -6437,7 +6437,18 @@ set at the end of parsing'/> - + @@ -6450,8 +6461,11 @@ set at the end of parsing'/> - - + + @@ -7523,7 +7537,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTML_ENABLED) Checks whether the tree node is valid. Experimental (the author only uses the HTML enhancements in a SAX parser) - + @@ -10595,7 +10609,7 @@ Could we use @subtypes for this?'/> Move all the element from the old list in the new list - + Create a new list @@ -10622,7 +10636,7 @@ Could we use @subtypes for this?'/> Duplicate the list - + Is the list empty ? @@ -12199,7 +12213,7 @@ Could we use @subtypes for this?'/> DEPRECATED: Don't use. Insert node info record into the sorted sequence - + Display and format an error messages, gives file, line, position and extra parameters. @@ -12211,14 +12225,14 @@ Could we use @subtypes for this?'/> DEPRECATED: Don't use. Find the parser node info struct for a given node - - + + DEPRECATED: Don't use. xmlParserFindNodeInfoIndex : Find the index that the info record for the given node is or should be at in a sorted sequence - - + + lookup the directory for that file diff --git a/testapi.c b/testapi.c index edebca6bf..aa36e5b2b 100644 --- a/testapi.c +++ b/testapi.c @@ -229,17 +229,6 @@ static void *gen_void_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { } -#if 0 -#define gen_nb_const_void_ptr 2 - -static const void *gen_const_void_ptr(int no, int nr ATTRIBUTE_UNUSED) { - if (no == 0) return((const void *) "immutable string"); - return(NULL); -} -static void des_const_void_ptr(int no ATTRIBUTE_UNUSED, const void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { -} -#endif - #define gen_nb_userdata 3 static void *gen_userdata(int no, int nr ATTRIBUTE_UNUSED) { @@ -372,7 +361,7 @@ static void des_int_ptr(int no ATTRIBUTE_UNUSED, int *val ATTRIBUTE_UNUSED, int #define gen_nb_const_char_ptr 4 -static char *gen_const_char_ptr(int no, int nr ATTRIBUTE_UNUSED) { +static const char *gen_const_char_ptr(int no, int nr ATTRIBUTE_UNUSED) { if (no == 0) return((char *) "foo"); if (no == 1) return((char *) ""); if (no == 2) return((char *) "test/ent2"); @@ -412,7 +401,7 @@ static void des_debug_FILE_ptr(int no ATTRIBUTE_UNUSED, FILE *val, int nr ATTRIB #define gen_nb_const_xmlChar_ptr 5 -static xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) { +static const xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) { if (no == 0) return((xmlChar *) "foo"); if (no == 1) return((xmlChar *) ""); if (no == 2) return((xmlChar *) "n" "\xf8" "ne"); @@ -885,7 +874,8 @@ static void desret_xmlNanoHTTPCtxtPtr(void *val) { #endif /* cut and pasted from autogenerated to avoid troubles */ #define gen_nb_const_xmlChar_ptr_ptr 1 -static xmlChar ** gen_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +static const xmlChar ** +gen_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { return(NULL); } static void des_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, const xmlChar ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { @@ -899,21 +889,13 @@ static void des_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, unsigned char * val A } #define gen_nb_const_unsigned_char_ptr 1 -static unsigned char * gen_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +static const unsigned char * +gen_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { return(NULL); } static void des_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, const unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { } -#ifdef LIBXML_HTML_ENABLED -#define gen_nb_const_htmlNodePtr 1 -static htmlNodePtr gen_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { - return(NULL); -} -static void des_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, const htmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { -} -#endif - #ifdef LIBXML_HTML_ENABLED #define gen_nb_htmlDocPtr 3 static htmlDocPtr gen_htmlDocPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { @@ -1313,7 +1295,7 @@ test_UTF8ToHtml(void) { int n_out; int * outlen; /* the length of @out */ int n_outlen; - unsigned char * in; /* a pointer to an array of UTF-8 chars */ + const unsigned char * in; /* a pointer to an array of UTF-8 chars */ int n_in; int * inlen; /* the length of @in */ int n_inlen; @@ -1328,12 +1310,12 @@ test_UTF8ToHtml(void) { in = gen_const_unsigned_char_ptr(n_in, 2); inlen = gen_int_ptr(n_inlen, 3); - ret_val = UTF8ToHtml(out, outlen, (const unsigned char *)in, inlen); + ret_val = UTF8ToHtml(out, outlen, in, inlen); desret_int(ret_val); call_tests++; des_unsigned_char_ptr(n_out, out, 0); des_int_ptr(n_outlen, outlen, 1); - des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_const_unsigned_char_ptr(n_in, in, 2); des_int_ptr(n_inlen, inlen, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -1371,9 +1353,9 @@ test_htmlAttrAllowed(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlStatus ret_val; - htmlElemDesc * elt; /* HTML element */ + const htmlElemDesc * elt; /* HTML element */ int n_elt; - xmlChar * attr; /* HTML attribute */ + const xmlChar * attr; /* HTML attribute */ int n_attr; int legacy; /* whether to allow deprecated attributes */ int n_legacy; @@ -1386,11 +1368,11 @@ test_htmlAttrAllowed(void) { attr = gen_const_xmlChar_ptr(n_attr, 1); legacy = gen_int(n_legacy, 2); - ret_val = htmlAttrAllowed((const htmlElemDesc *)elt, (const xmlChar *)attr, legacy); + ret_val = htmlAttrAllowed(elt, attr, legacy); desret_htmlStatus(ret_val); call_tests++; - des_const_htmlElemDesc_ptr(n_elt, (const htmlElemDesc *)elt, 0); - des_const_xmlChar_ptr(n_attr, (const xmlChar *)attr, 1); + des_const_htmlElemDesc_ptr(n_elt, elt, 0); + des_const_xmlChar_ptr(n_attr, attr, 1); des_int(n_legacy, legacy, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -1428,7 +1410,7 @@ test_htmlAutoCloseTag(void) { int ret_val; htmlDocPtr doc; /* the HTML document */ int n_doc; - xmlChar * name; /* The tag name */ + const xmlChar * name; /* The tag name */ int n_name; htmlNodePtr elem; /* the HTML element */ int n_elem; @@ -1441,11 +1423,11 @@ test_htmlAutoCloseTag(void) { name = gen_const_xmlChar_ptr(n_name, 1); elem = gen_htmlNodePtr(n_elem, 2); - ret_val = htmlAutoCloseTag(doc, (const xmlChar *)name, elem); + ret_val = htmlAutoCloseTag(doc, name, elem); desret_int(ret_val); call_tests++; des_htmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_htmlNodePtr(n_elem, elem, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -1476,7 +1458,7 @@ test_htmlCreateFileParserCtxt(void) { htmlParserCtxtPtr ret_val; const char * filename; /* the filename */ int n_filename; - char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ int n_encoding; for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { @@ -1485,11 +1467,11 @@ test_htmlCreateFileParserCtxt(void) { filename = gen_fileoutput(n_filename, 0); encoding = gen_const_char_ptr(n_encoding, 1); - ret_val = htmlCreateFileParserCtxt(filename, (const char *)encoding); + ret_val = htmlCreateFileParserCtxt(filename, encoding); desret_htmlParserCtxtPtr(ret_val); call_tests++; des_fileoutput(n_filename, filename, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_char_ptr(n_encoding, encoding, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlCreateFileParserCtxt", @@ -1515,7 +1497,7 @@ test_htmlCreateMemoryParserCtxt(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlParserCtxtPtr ret_val; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -1529,10 +1511,10 @@ test_htmlCreateMemoryParserCtxt(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = htmlCreateMemoryParserCtxt((const char *)buffer, size); + ret_val = htmlCreateMemoryParserCtxt(buffer, size); desret_htmlParserCtxtPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -1570,7 +1552,7 @@ test_htmlCreatePushParserCtxt(void) { int n_sax; void * user_data; /* The user data returned on SAX callbacks */ int n_user_data; - char * chunk; /* a pointer to an array of chars */ + const char * chunk; /* a pointer to an array of chars */ int n_chunk; int size; /* number of chars in the array */ int n_size; @@ -1596,12 +1578,12 @@ test_htmlCreatePushParserCtxt(void) { (size > xmlStrlen(BAD_CAST chunk))) size = 0; - ret_val = htmlCreatePushParserCtxt(sax, user_data, (const char *)chunk, size, filename, enc); + ret_val = htmlCreatePushParserCtxt(sax, user_data, chunk, size, filename, enc); desret_htmlParserCtxtPtr(ret_val); call_tests++; des_htmlSAXHandlerPtr(n_sax, sax, 0); des_userdata(n_user_data, user_data, 1); - des_const_char_ptr(n_chunk, (const char *)chunk, 2); + des_const_char_ptr(n_chunk, chunk, 2); des_int(n_size, size, 3); des_fileoutput(n_filename, filename, 4); des_xmlCharEncoding(n_enc, enc, 5); @@ -1640,11 +1622,11 @@ test_htmlCtxtReadDoc(void) { htmlDocPtr ret_val; htmlParserCtxtPtr ctxt; /* an HTML parser context */ int n_ctxt; - xmlChar * str; /* a pointer to a zero terminated string */ + const xmlChar * str; /* a pointer to a zero terminated string */ int n_str; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of htmlParserOption(s) */ int n_options; @@ -1661,13 +1643,13 @@ test_htmlCtxtReadDoc(void) { encoding = gen_const_char_ptr(n_encoding, 3); options = gen_int(n_options, 4); - ret_val = htmlCtxtReadDoc(ctxt, (const xmlChar *)str, URL, (const char *)encoding, options); + ret_val = htmlCtxtReadDoc(ctxt, str, URL, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); des_filepath(n_URL, URL, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_int(n_options, options, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -1703,7 +1685,7 @@ test_htmlCtxtReadFile(void) { int n_ctxt; const char * filename; /* a file or URL */ int n_filename; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of htmlParserOption(s) */ int n_options; @@ -1717,12 +1699,12 @@ test_htmlCtxtReadFile(void) { encoding = gen_const_char_ptr(n_encoding, 2); options = gen_int(n_options, 3); - ret_val = htmlCtxtReadFile(ctxt, filename, (const char *)encoding, options); + ret_val = htmlCtxtReadFile(ctxt, filename, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); des_filepath(n_filename, filename, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_int(n_options, options, 3); xmlResetLastError(); } @@ -1745,13 +1727,13 @@ test_htmlCtxtReadMemory(void) { htmlDocPtr ret_val; htmlParserCtxtPtr ctxt; /* an HTML parser context */ int n_ctxt; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of htmlParserOption(s) */ int n_options; @@ -1773,14 +1755,14 @@ test_htmlCtxtReadMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = htmlCtxtReadMemory(ctxt, (const char *)buffer, size, URL, (const char *)encoding, options); + ret_val = htmlCtxtReadMemory(ctxt, buffer, size, URL, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_const_char_ptr(n_buffer, buffer, 1); des_int(n_size, size, 2); des_filepath(n_URL, URL, 3); - des_const_char_ptr(n_encoding, (const char *)encoding, 4); + des_const_char_ptr(n_encoding, encoding, 4); des_int(n_options, options, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -1888,9 +1870,9 @@ test_htmlElementAllowedHere(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; int ret_val; - htmlElemDesc * parent; /* HTML parent element */ + const htmlElemDesc * parent; /* HTML parent element */ int n_parent; - xmlChar * elt; /* HTML element */ + const xmlChar * elt; /* HTML element */ int n_elt; for (n_parent = 0;n_parent < gen_nb_const_htmlElemDesc_ptr;n_parent++) { @@ -1899,11 +1881,11 @@ test_htmlElementAllowedHere(void) { parent = gen_const_htmlElemDesc_ptr(n_parent, 0); elt = gen_const_xmlChar_ptr(n_elt, 1); - ret_val = htmlElementAllowedHere((const htmlElemDesc *)parent, (const xmlChar *)elt); + ret_val = htmlElementAllowedHere(parent, elt); desret_int(ret_val); call_tests++; - des_const_htmlElemDesc_ptr(n_parent, (const htmlElemDesc *)parent, 0); - des_const_xmlChar_ptr(n_elt, (const xmlChar *)elt, 1); + des_const_htmlElemDesc_ptr(n_parent, parent, 0); + des_const_xmlChar_ptr(n_elt, elt, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlElementAllowedHere", @@ -1929,9 +1911,9 @@ test_htmlElementStatusHere(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlStatus ret_val; - htmlElemDesc * parent; /* HTML parent element */ + const htmlElemDesc * parent; /* HTML parent element */ int n_parent; - htmlElemDesc * elt; /* HTML element */ + const htmlElemDesc * elt; /* HTML element */ int n_elt; for (n_parent = 0;n_parent < gen_nb_const_htmlElemDesc_ptr;n_parent++) { @@ -1940,11 +1922,11 @@ test_htmlElementStatusHere(void) { parent = gen_const_htmlElemDesc_ptr(n_parent, 0); elt = gen_const_htmlElemDesc_ptr(n_elt, 1); - ret_val = htmlElementStatusHere((const htmlElemDesc *)parent, (const htmlElemDesc *)elt); + ret_val = htmlElementStatusHere(parent, elt); desret_htmlStatus(ret_val); call_tests++; - des_const_htmlElemDesc_ptr(n_parent, (const htmlElemDesc *)parent, 0); - des_const_htmlElemDesc_ptr(n_elt, (const htmlElemDesc *)elt, 1); + des_const_htmlElemDesc_ptr(n_parent, parent, 0); + des_const_htmlElemDesc_ptr(n_elt, elt, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlElementStatusHere", @@ -1974,7 +1956,7 @@ test_htmlEncodeEntities(void) { int n_out; int * outlen; /* the length of @out */ int n_outlen; - unsigned char * in; /* a pointer to an array of UTF-8 chars */ + const unsigned char * in; /* a pointer to an array of UTF-8 chars */ int n_in; int * inlen; /* the length of @in */ int n_inlen; @@ -1993,12 +1975,12 @@ test_htmlEncodeEntities(void) { inlen = gen_int_ptr(n_inlen, 3); quoteChar = gen_int(n_quoteChar, 4); - ret_val = htmlEncodeEntities(out, outlen, (const unsigned char *)in, inlen, quoteChar); + ret_val = htmlEncodeEntities(out, outlen, in, inlen, quoteChar); desret_int(ret_val); call_tests++; des_unsigned_char_ptr(n_out, out, 0); des_int_ptr(n_outlen, outlen, 1); - des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_const_unsigned_char_ptr(n_in, in, 2); des_int_ptr(n_inlen, inlen, 3); des_int(n_quoteChar, quoteChar, 4); xmlResetLastError(); @@ -2032,17 +2014,17 @@ test_htmlEntityLookup(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; const htmlEntityDesc * ret_val; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { mem_base = xmlMemBlocks(); name = gen_const_xmlChar_ptr(n_name, 0); - ret_val = htmlEntityLookup((const xmlChar *)name); + ret_val = htmlEntityLookup(name); desret_const_htmlEntityDesc_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlEntityLookup", @@ -2200,17 +2182,17 @@ test_htmlIsScriptAttribute(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; int ret_val; - xmlChar * name; /* an attribute name */ + const xmlChar * name; /* an attribute name */ int n_name; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { mem_base = xmlMemBlocks(); name = gen_const_xmlChar_ptr(n_name, 0); - ret_val = htmlIsScriptAttribute((const xmlChar *)name); + ret_val = htmlIsScriptAttribute(name); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlIsScriptAttribute", @@ -2268,7 +2250,7 @@ test_htmlNewSAXParserCtxt(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlParserCtxtPtr ret_val; - htmlSAXHandler * sax; /* SAX handler */ + const htmlSAXHandler * sax; /* SAX handler */ int n_sax; void * userData; /* user data */ int n_userData; @@ -2279,10 +2261,10 @@ test_htmlNewSAXParserCtxt(void) { sax = gen_const_htmlSAXHandler_ptr(n_sax, 0); userData = gen_userdata(n_userData, 1); - ret_val = htmlNewSAXParserCtxt((const htmlSAXHandler *)sax, userData); + ret_val = htmlNewSAXParserCtxt(sax, userData); desret_htmlParserCtxtPtr(ret_val); call_tests++; - des_const_htmlSAXHandler_ptr(n_sax, (const htmlSAXHandler *)sax, 0); + des_const_htmlSAXHandler_ptr(n_sax, sax, 0); des_userdata(n_userData, userData, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -2314,16 +2296,16 @@ test_htmlNodeStatus(void) { int legacy; /* whether to allow deprecated elements (YES is faster here for Element nodes) */ int n_legacy; - for (n_node = 0;n_node < gen_nb_const_htmlNodePtr;n_node++) { + for (n_node = 0;n_node < gen_nb_htmlNodePtr;n_node++) { for (n_legacy = 0;n_legacy < gen_nb_int;n_legacy++) { mem_base = xmlMemBlocks(); - node = gen_const_htmlNodePtr(n_node, 0); + node = gen_htmlNodePtr(n_node, 0); legacy = gen_int(n_legacy, 1); ret_val = htmlNodeStatus(node, legacy); desret_htmlStatus(ret_val); call_tests++; - des_const_htmlNodePtr(n_node, node, 0); + des_htmlNodePtr(n_node, node, 0); des_int(n_legacy, legacy, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -2386,7 +2368,7 @@ test_htmlParseChunk(void) { int ret_val; htmlParserCtxtPtr ctxt; /* an HTML parser context */ int n_ctxt; - char * chunk; /* an char array */ + const char * chunk; /* an char array */ int n_chunk; int size; /* the size in byte of the chunk */ int n_size; @@ -2406,12 +2388,12 @@ test_htmlParseChunk(void) { (size > xmlStrlen(BAD_CAST chunk))) size = 0; - ret_val = htmlParseChunk(ctxt, (const char *)chunk, size, terminate); + ret_val = htmlParseChunk(ctxt, chunk, size, terminate); if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} desret_int(ret_val); call_tests++; des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_char_ptr(n_chunk, (const char *)chunk, 1); + des_const_char_ptr(n_chunk, chunk, 1); des_int(n_size, size, 2); des_int(n_terminate, terminate, 3); xmlResetLastError(); @@ -2443,9 +2425,9 @@ test_htmlParseDoc(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlDocPtr ret_val; - xmlChar * cur; /* a pointer to an array of xmlChar */ + const xmlChar * cur; /* a pointer to an array of xmlChar */ int n_cur; - char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ int n_encoding; for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { @@ -2454,11 +2436,11 @@ test_htmlParseDoc(void) { cur = gen_const_xmlChar_ptr(n_cur, 0); encoding = gen_const_char_ptr(n_encoding, 1); - ret_val = htmlParseDoc((const xmlChar *)cur, (const char *)encoding); + ret_val = htmlParseDoc(cur, encoding); desret_htmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_xmlChar_ptr(n_cur, cur, 0); + des_const_char_ptr(n_encoding, encoding, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlParseDoc", @@ -2553,7 +2535,7 @@ test_htmlParseEntityRef(void) { const htmlEntityDesc * ret_val; htmlParserCtxtPtr ctxt; /* an HTML parser context */ int n_ctxt; - xmlChar ** str; /* location to store the entity name */ + const xmlChar ** str; /* location to store the entity name */ int n_str; for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { @@ -2562,11 +2544,11 @@ test_htmlParseEntityRef(void) { ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); str = gen_const_xmlChar_ptr_ptr(n_str, 1); - ret_val = htmlParseEntityRef(ctxt, (const xmlChar **)str); + ret_val = htmlParseEntityRef(ctxt, str); desret_const_htmlEntityDesc_ptr(ret_val); call_tests++; des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr_ptr(n_str, (const xmlChar **)str, 1); + des_const_xmlChar_ptr_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlParseEntityRef", @@ -2593,7 +2575,7 @@ test_htmlParseFile(void) { htmlDocPtr ret_val; const char * filename; /* the filename */ int n_filename; - char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ int n_encoding; for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { @@ -2601,11 +2583,11 @@ test_htmlParseFile(void) { filename = gen_filepath(n_filename, 0); encoding = gen_const_char_ptr(n_encoding, 1); - ret_val = htmlParseFile(filename, (const char *)encoding); + ret_val = htmlParseFile(filename, encoding); desret_htmlDocPtr(ret_val); call_tests++; des_filepath(n_filename, filename, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_char_ptr(n_encoding, encoding, 1); xmlResetLastError(); } } @@ -2623,11 +2605,11 @@ test_htmlReadDoc(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlDocPtr ret_val; - xmlChar * cur; /* a pointer to a zero terminated string */ + const xmlChar * cur; /* a pointer to a zero terminated string */ int n_cur; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of htmlParserOption(s) */ int n_options; @@ -2642,12 +2624,12 @@ test_htmlReadDoc(void) { encoding = gen_const_char_ptr(n_encoding, 2); options = gen_int(n_options, 3); - ret_val = htmlReadDoc((const xmlChar *)cur, URL, (const char *)encoding, options); + ret_val = htmlReadDoc(cur, URL, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_xmlChar_ptr(n_cur, cur, 0); des_filepath(n_URL, URL, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_int(n_options, options, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -2680,7 +2662,7 @@ test_htmlReadFile(void) { htmlDocPtr ret_val; const char * filename; /* a file or URL */ int n_filename; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of htmlParserOption(s) */ int n_options; @@ -2693,11 +2675,11 @@ test_htmlReadFile(void) { encoding = gen_const_char_ptr(n_encoding, 1); options = gen_int(n_options, 2); - ret_val = htmlReadFile(filename, (const char *)encoding, options); + ret_val = htmlReadFile(filename, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; des_filepath(n_filename, filename, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_char_ptr(n_encoding, encoding, 1); des_int(n_options, options, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -2726,13 +2708,13 @@ test_htmlReadMemory(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlDocPtr ret_val; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of htmlParserOption(s) */ int n_options; @@ -2752,13 +2734,13 @@ test_htmlReadMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = htmlReadMemory((const char *)buffer, size, URL, (const char *)encoding, options); + ret_val = htmlReadMemory(buffer, size, URL, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); des_filepath(n_URL, URL, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_int(n_options, options, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -2791,9 +2773,9 @@ test_htmlSAXParseDoc(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlDocPtr ret_val; - xmlChar * cur; /* a pointer to an array of xmlChar */ + const xmlChar * cur; /* a pointer to an array of xmlChar */ int n_cur; - char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ int n_encoding; htmlSAXHandlerPtr sax; /* the SAX handler block */ int n_sax; @@ -2810,11 +2792,11 @@ test_htmlSAXParseDoc(void) { sax = gen_htmlSAXHandlerPtr(n_sax, 2); userData = gen_userdata(n_userData, 3); - ret_val = htmlSAXParseDoc((const xmlChar *)cur, (const char *)encoding, sax, userData); + ret_val = htmlSAXParseDoc(cur, encoding, sax, userData); desret_htmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_xmlChar_ptr(n_cur, cur, 0); + des_const_char_ptr(n_encoding, encoding, 1); des_htmlSAXHandlerPtr(n_sax, sax, 2); des_userdata(n_userData, userData, 3); xmlResetLastError(); @@ -2848,7 +2830,7 @@ test_htmlSAXParseFile(void) { htmlDocPtr ret_val; const char * filename; /* the filename */ int n_filename; - char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ int n_encoding; htmlSAXHandlerPtr sax; /* the SAX handler block */ int n_sax; @@ -2865,11 +2847,11 @@ test_htmlSAXParseFile(void) { sax = gen_htmlSAXHandlerPtr(n_sax, 2); userData = gen_userdata(n_userData, 3); - ret_val = htmlSAXParseFile(filename, (const char *)encoding, sax, userData); + ret_val = htmlSAXParseFile(filename, encoding, sax, userData); desret_htmlDocPtr(ret_val); call_tests++; des_filepath(n_filename, filename, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_char_ptr(n_encoding, encoding, 1); des_htmlSAXHandlerPtr(n_sax, sax, 2); des_userdata(n_userData, userData, 3); xmlResetLastError(); @@ -2960,7 +2942,7 @@ test_htmlDocContentDumpFormatOutput(void) { int n_buf; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the encoding string (unused) */ + const char * encoding; /* the encoding string (unused) */ int n_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -2975,11 +2957,11 @@ test_htmlDocContentDumpFormatOutput(void) { encoding = gen_const_char_ptr(n_encoding, 2); format = gen_int(n_format, 3); - htmlDocContentDumpFormatOutput(buf, cur, (const char *)encoding, format); + htmlDocContentDumpFormatOutput(buf, cur, encoding, format); call_tests++; des_xmlOutputBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_int(n_format, format, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -3013,7 +2995,7 @@ test_htmlDocContentDumpOutput(void) { int n_buf; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the encoding string (unused) */ + const char * encoding; /* the encoding string (unused) */ int n_encoding; for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { @@ -3024,11 +3006,11 @@ test_htmlDocContentDumpOutput(void) { cur = gen_xmlDocPtr(n_cur, 1); encoding = gen_const_char_ptr(n_encoding, 2); - htmlDocContentDumpOutput(buf, cur, (const char *)encoding); + htmlDocContentDumpOutput(buf, cur, encoding); call_tests++; des_xmlOutputBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlDocContentDumpOutput", @@ -3234,17 +3216,17 @@ test_htmlIsBooleanAttr(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; int ret_val; - xmlChar * name; /* the name of the attribute to check */ + const xmlChar * name; /* the name of the attribute to check */ int n_name; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { mem_base = xmlMemBlocks(); name = gen_const_xmlChar_ptr(n_name, 0); - ret_val = htmlIsBooleanAttr((const xmlChar *)name); + ret_val = htmlIsBooleanAttr(name); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlIsBooleanAttr", @@ -3268,9 +3250,9 @@ test_htmlNewDoc(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlDocPtr ret_val; - xmlChar * URI; /* URI for the dtd, or NULL */ + const xmlChar * URI; /* URI for the dtd, or NULL */ int n_URI; - xmlChar * ExternalID; /* the external ID of the DTD, or NULL */ + const xmlChar * ExternalID; /* the external ID of the DTD, or NULL */ int n_ExternalID; for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { @@ -3279,11 +3261,11 @@ test_htmlNewDoc(void) { URI = gen_const_xmlChar_ptr(n_URI, 0); ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1); - ret_val = htmlNewDoc((const xmlChar *)URI, (const xmlChar *)ExternalID); + ret_val = htmlNewDoc(URI, ExternalID); desret_htmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 1); + des_const_xmlChar_ptr(n_URI, URI, 0); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlNewDoc", @@ -3309,9 +3291,9 @@ test_htmlNewDocNoDtD(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlDocPtr ret_val; - xmlChar * URI; /* URI for the dtd, or NULL */ + const xmlChar * URI; /* URI for the dtd, or NULL */ int n_URI; - xmlChar * ExternalID; /* the external ID of the DTD, or NULL */ + const xmlChar * ExternalID; /* the external ID of the DTD, or NULL */ int n_ExternalID; for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { @@ -3320,11 +3302,11 @@ test_htmlNewDocNoDtD(void) { URI = gen_const_xmlChar_ptr(n_URI, 0); ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1); - ret_val = htmlNewDocNoDtD((const xmlChar *)URI, (const xmlChar *)ExternalID); + ret_val = htmlNewDocNoDtD(URI, ExternalID); desret_htmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 1); + des_const_xmlChar_ptr(n_URI, URI, 0); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlNewDocNoDtD", @@ -3450,7 +3432,7 @@ test_htmlNodeDumpFileFormat(void) { int n_doc; xmlNodePtr cur; /* the current node */ int n_cur; - char * encoding; /* the document encoding */ + const char * encoding; /* the document encoding */ int n_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -3467,13 +3449,13 @@ test_htmlNodeDumpFileFormat(void) { encoding = gen_const_char_ptr(n_encoding, 3); format = gen_int(n_format, 4); - ret_val = htmlNodeDumpFileFormat(out, doc, cur, (const char *)encoding, format); + ret_val = htmlNodeDumpFileFormat(out, doc, cur, encoding, format); desret_int(ret_val); call_tests++; des_FILE_ptr(n_out, out, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_cur, cur, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_int(n_format, format, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -3511,7 +3493,7 @@ test_htmlNodeDumpFormatOutput(void) { int n_doc; xmlNodePtr cur; /* the current node */ int n_cur; - char * encoding; /* the encoding string (unused) */ + const char * encoding; /* the encoding string (unused) */ int n_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -3528,12 +3510,12 @@ test_htmlNodeDumpFormatOutput(void) { encoding = gen_const_char_ptr(n_encoding, 3); format = gen_int(n_format, 4); - htmlNodeDumpFormatOutput(buf, doc, cur, (const char *)encoding, format); + htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format); call_tests++; des_xmlOutputBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_cur, cur, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_int(n_format, format, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -3571,7 +3553,7 @@ test_htmlNodeDumpOutput(void) { int n_doc; xmlNodePtr cur; /* the current node */ int n_cur; - char * encoding; /* the encoding string (unused) */ + const char * encoding; /* the encoding string (unused) */ int n_encoding; for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { @@ -3584,12 +3566,12 @@ test_htmlNodeDumpOutput(void) { cur = gen_xmlNodePtr(n_cur, 2); encoding = gen_const_char_ptr(n_encoding, 3); - htmlNodeDumpOutput(buf, doc, cur, (const char *)encoding); + htmlNodeDumpOutput(buf, doc, cur, encoding); call_tests++; des_xmlOutputBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_cur, cur, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlNodeDumpOutput", @@ -3664,7 +3646,7 @@ test_htmlSaveFileEnc(void) { int n_filename; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the document encoding */ + const char * encoding; /* the document encoding */ int n_encoding; for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { @@ -3675,12 +3657,12 @@ test_htmlSaveFileEnc(void) { cur = gen_xmlDocPtr(n_cur, 1); encoding = gen_const_char_ptr(n_encoding, 2); - ret_val = htmlSaveFileEnc(filename, cur, (const char *)encoding); + ret_val = htmlSaveFileEnc(filename, cur, encoding); desret_int(ret_val); call_tests++; des_fileoutput(n_filename, filename, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlSaveFileEnc", @@ -3712,7 +3694,7 @@ test_htmlSaveFileFormat(void) { int n_filename; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the document encoding */ + const char * encoding; /* the document encoding */ int n_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -3727,12 +3709,12 @@ test_htmlSaveFileFormat(void) { encoding = gen_const_char_ptr(n_encoding, 2); format = gen_int(n_format, 3); - ret_val = htmlSaveFileFormat(filename, cur, (const char *)encoding, format); + ret_val = htmlSaveFileFormat(filename, cur, encoding, format); desret_int(ret_val); call_tests++; des_fileoutput(n_filename, filename, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_int(n_format, format, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -3765,7 +3747,7 @@ test_htmlSetMetaEncoding(void) { int ret_val; htmlDocPtr doc; /* the document */ int n_doc; - xmlChar * encoding; /* the encoding string */ + const xmlChar * encoding; /* the encoding string */ int n_encoding; for (n_doc = 0;n_doc < gen_nb_htmlDocPtr;n_doc++) { @@ -3774,11 +3756,11 @@ test_htmlSetMetaEncoding(void) { doc = gen_htmlDocPtr(n_doc, 0); encoding = gen_const_xmlChar_ptr(n_encoding, 1); - ret_val = htmlSetMetaEncoding(doc, (const xmlChar *)encoding); + ret_val = htmlSetMetaEncoding(doc, encoding); desret_int(ret_val); call_tests++; des_htmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_encoding, (const xmlChar *)encoding, 1); + des_const_xmlChar_ptr(n_encoding, encoding, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in htmlSetMetaEncoding", @@ -3886,15 +3868,15 @@ test_xmlSAX2AttributeDecl(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * elem; /* the name of the element */ + const xmlChar * elem; /* the name of the element */ int n_elem; - xmlChar * fullname; /* the attribute name */ + const xmlChar * fullname; /* the attribute name */ int n_fullname; int type; /* the attribute type */ int n_type; int def; /* the type of default value */ int n_def; - xmlChar * defaultValue; /* the attribute default value */ + const xmlChar * defaultValue; /* the attribute default value */ int n_defaultValue; xmlEnumerationPtr tree; /* the tree of enumerated value set */ int n_tree; @@ -3915,14 +3897,14 @@ test_xmlSAX2AttributeDecl(void) { defaultValue = gen_const_xmlChar_ptr(n_defaultValue, 5); tree = gen_xmlEnumerationPtr(n_tree, 6); - xmlSAX2AttributeDecl(ctx, (const xmlChar *)elem, (const xmlChar *)fullname, type, def, (const xmlChar *)defaultValue, tree); + xmlSAX2AttributeDecl(ctx, elem, fullname, type, def, defaultValue, tree); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 1); - des_const_xmlChar_ptr(n_fullname, (const xmlChar *)fullname, 2); + des_const_xmlChar_ptr(n_elem, elem, 1); + des_const_xmlChar_ptr(n_fullname, fullname, 2); des_int(n_type, type, 3); des_int(n_def, def, 4); - des_const_xmlChar_ptr(n_defaultValue, (const xmlChar *)defaultValue, 5); + des_const_xmlChar_ptr(n_defaultValue, defaultValue, 5); des_xmlEnumerationPtr(n_tree, tree, 6); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -3958,7 +3940,7 @@ test_xmlSAX2CDataBlock(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * value; /* The pcdata content */ + const xmlChar * value; /* The pcdata content */ int n_value; int len; /* the block length */ int n_len; @@ -3974,10 +3956,10 @@ test_xmlSAX2CDataBlock(void) { (len > xmlStrlen(BAD_CAST value))) len = 0; - xmlSAX2CDataBlock(ctx, (const xmlChar *)value, len); + xmlSAX2CDataBlock(ctx, value, len); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -4005,7 +3987,7 @@ test_xmlSAX2Characters(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * ch; /* a xmlChar string */ + const xmlChar * ch; /* a xmlChar string */ int n_ch; int len; /* the number of xmlChar */ int n_len; @@ -4021,10 +4003,10 @@ test_xmlSAX2Characters(void) { (len > xmlStrlen(BAD_CAST ch))) len = 0; - xmlSAX2Characters(ctx, (const xmlChar *)ch, len); + xmlSAX2Characters(ctx, ch, len); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_ch, (const xmlChar *)ch, 1); + des_const_xmlChar_ptr(n_ch, ch, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -4052,7 +4034,7 @@ test_xmlSAX2Comment(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * value; /* the xmlSAX2Comment content */ + const xmlChar * value; /* the xmlSAX2Comment content */ int n_value; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4061,10 +4043,10 @@ test_xmlSAX2Comment(void) { ctx = gen_void_ptr(n_ctx, 0); value = gen_const_xmlChar_ptr(n_value, 1); - xmlSAX2Comment(ctx, (const xmlChar *)value); + xmlSAX2Comment(ctx, value); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2Comment", @@ -4089,7 +4071,7 @@ test_xmlSAX2ElementDecl(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* the element name */ + const xmlChar * name; /* the element name */ int n_name; int type; /* the element type */ int n_type; @@ -4106,10 +4088,10 @@ test_xmlSAX2ElementDecl(void) { type = gen_int(n_type, 2); content = gen_xmlElementContentPtr(n_content, 3); - xmlSAX2ElementDecl(ctx, (const xmlChar *)name, type, content); + xmlSAX2ElementDecl(ctx, name, type, content); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_int(n_type, type, 2); des_xmlElementContentPtr(n_content, content, 3); xmlResetLastError(); @@ -4172,7 +4154,7 @@ test_xmlSAX2EndElement(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* The element name */ + const xmlChar * name; /* The element name */ int n_name; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4181,10 +4163,10 @@ test_xmlSAX2EndElement(void) { ctx = gen_void_ptr(n_ctx, 0); name = gen_const_xmlChar_ptr(n_name, 1); - xmlSAX2EndElement(ctx, (const xmlChar *)name); + xmlSAX2EndElement(ctx, name); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2EndElement", @@ -4211,11 +4193,11 @@ test_xmlSAX2EndElementNs(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * localname; /* the local name of the element */ + const xmlChar * localname; /* the local name of the element */ int n_localname; - xmlChar * prefix; /* the element namespace prefix if available */ + const xmlChar * prefix; /* the element namespace prefix if available */ int n_prefix; - xmlChar * URI; /* the element namespace name if available */ + const xmlChar * URI; /* the element namespace name if available */ int n_URI; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4228,12 +4210,12 @@ test_xmlSAX2EndElementNs(void) { prefix = gen_const_xmlChar_ptr(n_prefix, 2); URI = gen_const_xmlChar_ptr(n_URI, 3); - xmlSAX2EndElementNs(ctx, (const xmlChar *)localname, (const xmlChar *)prefix, (const xmlChar *)URI); + xmlSAX2EndElementNs(ctx, localname, prefix, URI); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_localname, (const xmlChar *)localname, 1); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 3); + des_const_xmlChar_ptr(n_localname, localname, 1); + des_const_xmlChar_ptr(n_prefix, prefix, 2); + des_const_xmlChar_ptr(n_URI, URI, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2EndElementNs", @@ -4262,13 +4244,13 @@ test_xmlSAX2EntityDecl(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; int type; /* the entity type */ int n_type; - xmlChar * publicId; /* The public ID of the entity */ + const xmlChar * publicId; /* The public ID of the entity */ int n_publicId; - xmlChar * systemId; /* The system ID of the entity */ + const xmlChar * systemId; /* The system ID of the entity */ int n_systemId; xmlChar * content; /* the entity value (without processing). */ int n_content; @@ -4287,13 +4269,13 @@ test_xmlSAX2EntityDecl(void) { systemId = gen_const_xmlChar_ptr(n_systemId, 4); content = gen_xmlChar_ptr(n_content, 5); - xmlSAX2EntityDecl(ctx, (const xmlChar *)name, type, (const xmlChar *)publicId, (const xmlChar *)systemId, content); + xmlSAX2EntityDecl(ctx, name, type, publicId, systemId, content); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_int(n_type, type, 2); - des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 3); - des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 4); + des_const_xmlChar_ptr(n_publicId, publicId, 3); + des_const_xmlChar_ptr(n_systemId, systemId, 4); des_xmlChar_ptr(n_content, content, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -4327,11 +4309,11 @@ test_xmlSAX2ExternalSubset(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* the root element name */ + const xmlChar * name; /* the root element name */ int n_name; - xmlChar * ExternalID; /* the external ID */ + const xmlChar * ExternalID; /* the external ID */ int n_ExternalID; - xmlChar * SystemID; /* the SYSTEM ID (e.g. filename or URL) */ + const xmlChar * SystemID; /* the SYSTEM ID (e.g. filename or URL) */ int n_SystemID; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4344,12 +4326,12 @@ test_xmlSAX2ExternalSubset(void) { ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); - xmlSAX2ExternalSubset(ctx, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + xmlSAX2ExternalSubset(ctx, name, ExternalID, SystemID); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, SystemID, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2ExternalSubset", @@ -4411,7 +4393,7 @@ test_xmlSAX2GetEntity(void) { xmlEntityPtr ret_val; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* The entity name */ + const xmlChar * name; /* The entity name */ int n_name; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4420,11 +4402,11 @@ test_xmlSAX2GetEntity(void) { ctx = gen_void_ptr(n_ctx, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlSAX2GetEntity(ctx, (const xmlChar *)name); + ret_val = xmlSAX2GetEntity(ctx, name); desret_xmlEntityPtr(ret_val); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2GetEntity", @@ -4482,7 +4464,7 @@ test_xmlSAX2GetParameterEntity(void) { xmlEntityPtr ret_val; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* The entity name */ + const xmlChar * name; /* The entity name */ int n_name; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4491,11 +4473,11 @@ test_xmlSAX2GetParameterEntity(void) { ctx = gen_void_ptr(n_ctx, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlSAX2GetParameterEntity(ctx, (const xmlChar *)name); + ret_val = xmlSAX2GetParameterEntity(ctx, name); desret_xmlEntityPtr(ret_val); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2GetParameterEntity", @@ -4648,7 +4630,7 @@ test_xmlSAX2IgnorableWhitespace(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * ch; /* a xmlChar string */ + const xmlChar * ch; /* a xmlChar string */ int n_ch; int len; /* the number of xmlChar */ int n_len; @@ -4664,10 +4646,10 @@ test_xmlSAX2IgnorableWhitespace(void) { (len > xmlStrlen(BAD_CAST ch))) len = 0; - xmlSAX2IgnorableWhitespace(ctx, (const xmlChar *)ch, len); + xmlSAX2IgnorableWhitespace(ctx, ch, len); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_ch, (const xmlChar *)ch, 1); + des_const_xmlChar_ptr(n_ch, ch, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -4768,11 +4750,11 @@ test_xmlSAX2InternalSubset(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* the root element name */ + const xmlChar * name; /* the root element name */ int n_name; - xmlChar * ExternalID; /* the external ID */ + const xmlChar * ExternalID; /* the external ID */ int n_ExternalID; - xmlChar * SystemID; /* the SYSTEM ID (e.g. filename or URL) */ + const xmlChar * SystemID; /* the SYSTEM ID (e.g. filename or URL) */ int n_SystemID; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4785,12 +4767,12 @@ test_xmlSAX2InternalSubset(void) { ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); - xmlSAX2InternalSubset(ctx, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + xmlSAX2InternalSubset(ctx, name, ExternalID, SystemID); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, SystemID, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2InternalSubset", @@ -4851,11 +4833,11 @@ test_xmlSAX2NotationDecl(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* The name of the notation */ + const xmlChar * name; /* The name of the notation */ int n_name; - xmlChar * publicId; /* The public ID of the entity */ + const xmlChar * publicId; /* The public ID of the entity */ int n_publicId; - xmlChar * systemId; /* The system ID of the entity */ + const xmlChar * systemId; /* The system ID of the entity */ int n_systemId; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4868,12 +4850,12 @@ test_xmlSAX2NotationDecl(void) { publicId = gen_const_xmlChar_ptr(n_publicId, 2); systemId = gen_const_xmlChar_ptr(n_systemId, 3); - xmlSAX2NotationDecl(ctx, (const xmlChar *)name, (const xmlChar *)publicId, (const xmlChar *)systemId); + xmlSAX2NotationDecl(ctx, name, publicId, systemId); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 2); - des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 3); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_publicId, publicId, 2); + des_const_xmlChar_ptr(n_systemId, systemId, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2NotationDecl", @@ -4902,9 +4884,9 @@ test_xmlSAX2ProcessingInstruction(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * target; /* the target name */ + const xmlChar * target; /* the target name */ int n_target; - xmlChar * data; /* the PI data's */ + const xmlChar * data; /* the PI data's */ int n_data; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4915,11 +4897,11 @@ test_xmlSAX2ProcessingInstruction(void) { target = gen_const_xmlChar_ptr(n_target, 1); data = gen_const_xmlChar_ptr(n_data, 2); - xmlSAX2ProcessingInstruction(ctx, (const xmlChar *)target, (const xmlChar *)data); + xmlSAX2ProcessingInstruction(ctx, target, data); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_target, (const xmlChar *)target, 1); - des_const_xmlChar_ptr(n_data, (const xmlChar *)data, 2); + des_const_xmlChar_ptr(n_target, target, 1); + des_const_xmlChar_ptr(n_data, data, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2ProcessingInstruction", @@ -4946,7 +4928,7 @@ test_xmlSAX2Reference(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* The entity name */ + const xmlChar * name; /* The entity name */ int n_name; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4955,10 +4937,10 @@ test_xmlSAX2Reference(void) { ctx = gen_void_ptr(n_ctx, 0); name = gen_const_xmlChar_ptr(n_name, 1); - xmlSAX2Reference(ctx, (const xmlChar *)name); + xmlSAX2Reference(ctx, name); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2Reference", @@ -4984,9 +4966,9 @@ test_xmlSAX2ResolveEntity(void) { xmlParserInputPtr ret_val; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * publicId; /* The public ID of the entity */ + const xmlChar * publicId; /* The public ID of the entity */ int n_publicId; - xmlChar * systemId; /* The system ID of the entity */ + const xmlChar * systemId; /* The system ID of the entity */ int n_systemId; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -4997,12 +4979,12 @@ test_xmlSAX2ResolveEntity(void) { publicId = gen_const_xmlChar_ptr(n_publicId, 1); systemId = gen_const_xmlChar_ptr(n_systemId, 2); - ret_val = xmlSAX2ResolveEntity(ctx, (const xmlChar *)publicId, (const xmlChar *)systemId); + ret_val = xmlSAX2ResolveEntity(ctx, publicId, systemId); desret_xmlParserInputPtr(ret_val); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 1); - des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 2); + des_const_xmlChar_ptr(n_publicId, publicId, 1); + des_const_xmlChar_ptr(n_systemId, systemId, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2ResolveEntity", @@ -5102,9 +5084,9 @@ test_xmlSAX2StartElement(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * fullname; /* The element name, including namespace prefix */ + const xmlChar * fullname; /* The element name, including namespace prefix */ int n_fullname; - xmlChar ** atts; /* An array of name/value attributes pairs, NULL terminated */ + const xmlChar ** atts; /* An array of name/value attributes pairs, NULL terminated */ int n_atts; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -5115,11 +5097,11 @@ test_xmlSAX2StartElement(void) { fullname = gen_const_xmlChar_ptr(n_fullname, 1); atts = gen_const_xmlChar_ptr_ptr(n_atts, 2); - xmlSAX2StartElement(ctx, (const xmlChar *)fullname, (const xmlChar **)atts); + xmlSAX2StartElement(ctx, fullname, atts); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_fullname, (const xmlChar *)fullname, 1); - des_const_xmlChar_ptr_ptr(n_atts, (const xmlChar **)atts, 2); + des_const_xmlChar_ptr(n_fullname, fullname, 1); + des_const_xmlChar_ptr_ptr(n_atts, atts, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2StartElement", @@ -5148,21 +5130,21 @@ test_xmlSAX2StartElementNs(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * localname; /* the local name of the element */ + const xmlChar * localname; /* the local name of the element */ int n_localname; - xmlChar * prefix; /* the element namespace prefix if available */ + const xmlChar * prefix; /* the element namespace prefix if available */ int n_prefix; - xmlChar * URI; /* the element namespace name if available */ + const xmlChar * URI; /* the element namespace name if available */ int n_URI; int nb_namespaces; /* number of namespace definitions on that node */ int n_nb_namespaces; - xmlChar ** namespaces; /* pointer to the array of prefix/URI pairs namespace definitions */ + const xmlChar ** namespaces; /* pointer to the array of prefix/URI pairs namespace definitions */ int n_namespaces; int nb_attributes; /* the number of attributes on that node */ int n_nb_attributes; int nb_defaulted; /* the number of defaulted attributes. */ int n_nb_defaulted; - xmlChar ** attributes; /* pointer to the array of (localname/prefix/URI/value/end) attribute values. */ + const xmlChar ** attributes; /* pointer to the array of (localname/prefix/URI/value/end) attribute values. */ int n_attributes; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -5185,17 +5167,17 @@ test_xmlSAX2StartElementNs(void) { nb_defaulted = gen_int(n_nb_defaulted, 7); attributes = gen_const_xmlChar_ptr_ptr(n_attributes, 8); - xmlSAX2StartElementNs(ctx, (const xmlChar *)localname, (const xmlChar *)prefix, (const xmlChar *)URI, nb_namespaces, (const xmlChar **)namespaces, nb_attributes, nb_defaulted, (const xmlChar **)attributes); + xmlSAX2StartElementNs(ctx, localname, prefix, URI, nb_namespaces, namespaces, nb_attributes, nb_defaulted, attributes); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_localname, (const xmlChar *)localname, 1); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 3); + des_const_xmlChar_ptr(n_localname, localname, 1); + des_const_xmlChar_ptr(n_prefix, prefix, 2); + des_const_xmlChar_ptr(n_URI, URI, 3); des_int(n_nb_namespaces, nb_namespaces, 4); - des_const_xmlChar_ptr_ptr(n_namespaces, (const xmlChar **)namespaces, 5); + des_const_xmlChar_ptr_ptr(n_namespaces, namespaces, 5); des_int(n_nb_attributes, nb_attributes, 6); des_int(n_nb_defaulted, nb_defaulted, 7); - des_const_xmlChar_ptr_ptr(n_attributes, (const xmlChar **)attributes, 8); + des_const_xmlChar_ptr_ptr(n_attributes, attributes, 8); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2StartElementNs", @@ -5234,13 +5216,13 @@ test_xmlSAX2UnparsedEntityDecl(void) { int mem_base; void * ctx; /* the user data (XML parser context) */ int n_ctx; - xmlChar * name; /* The name of the entity */ + const xmlChar * name; /* The name of the entity */ int n_name; - xmlChar * publicId; /* The public ID of the entity */ + const xmlChar * publicId; /* The public ID of the entity */ int n_publicId; - xmlChar * systemId; /* The system ID of the entity */ + const xmlChar * systemId; /* The system ID of the entity */ int n_systemId; - xmlChar * notationName; /* the name of the notation */ + const xmlChar * notationName; /* the name of the notation */ int n_notationName; for (n_ctx = 0;n_ctx < gen_nb_void_ptr;n_ctx++) { @@ -5255,13 +5237,13 @@ test_xmlSAX2UnparsedEntityDecl(void) { systemId = gen_const_xmlChar_ptr(n_systemId, 3); notationName = gen_const_xmlChar_ptr(n_notationName, 4); - xmlSAX2UnparsedEntityDecl(ctx, (const xmlChar *)name, (const xmlChar *)publicId, (const xmlChar *)systemId, (const xmlChar *)notationName); + xmlSAX2UnparsedEntityDecl(ctx, name, publicId, systemId, notationName); call_tests++; des_void_ptr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_publicId, (const xmlChar *)publicId, 2); - des_const_xmlChar_ptr(n_systemId, (const xmlChar *)systemId, 3); - des_const_xmlChar_ptr(n_notationName, (const xmlChar *)notationName, 4); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_publicId, publicId, 2); + des_const_xmlChar_ptr(n_systemId, systemId, 3); + des_const_xmlChar_ptr(n_notationName, notationName, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAX2UnparsedEntityDecl", @@ -5668,11 +5650,11 @@ test_xmlACatalogAdd(void) { int ret_val; xmlCatalogPtr catal; /* a Catalog */ int n_catal; - xmlChar * type; /* the type of record to add to the catalog */ + const xmlChar * type; /* the type of record to add to the catalog */ int n_type; - xmlChar * orig; /* the system, public or prefix to match */ + const xmlChar * orig; /* the system, public or prefix to match */ int n_orig; - xmlChar * replace; /* the replacement value for the match */ + const xmlChar * replace; /* the replacement value for the match */ int n_replace; for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { @@ -5685,13 +5667,13 @@ test_xmlACatalogAdd(void) { orig = gen_const_xmlChar_ptr(n_orig, 2); replace = gen_const_xmlChar_ptr(n_replace, 3); - ret_val = xmlACatalogAdd(catal, (const xmlChar *)type, (const xmlChar *)orig, (const xmlChar *)replace); + ret_val = xmlACatalogAdd(catal, type, orig, replace); desret_int(ret_val); call_tests++; des_xmlCatalogPtr(n_catal, catal, 0); - des_const_xmlChar_ptr(n_type, (const xmlChar *)type, 1); - des_const_xmlChar_ptr(n_orig, (const xmlChar *)orig, 2); - des_const_xmlChar_ptr(n_replace, (const xmlChar *)replace, 3); + des_const_xmlChar_ptr(n_type, type, 1); + des_const_xmlChar_ptr(n_orig, orig, 2); + des_const_xmlChar_ptr(n_replace, replace, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlACatalogAdd", @@ -5762,7 +5744,7 @@ test_xmlACatalogRemove(void) { int ret_val; xmlCatalogPtr catal; /* a Catalog */ int n_catal; - xmlChar * value; /* the value to remove */ + const xmlChar * value; /* the value to remove */ int n_value; for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { @@ -5771,11 +5753,11 @@ test_xmlACatalogRemove(void) { catal = gen_xmlCatalogPtr(n_catal, 0); value = gen_const_xmlChar_ptr(n_value, 1); - ret_val = xmlACatalogRemove(catal, (const xmlChar *)value); + ret_val = xmlACatalogRemove(catal, value); desret_int(ret_val); call_tests++; des_xmlCatalogPtr(n_catal, catal, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlACatalogRemove", @@ -5803,9 +5785,9 @@ test_xmlACatalogResolve(void) { xmlChar * ret_val; xmlCatalogPtr catal; /* a Catalog */ int n_catal; - xmlChar * pubID; /* the public ID string */ + const xmlChar * pubID; /* the public ID string */ int n_pubID; - xmlChar * sysID; /* the system ID string */ + const xmlChar * sysID; /* the system ID string */ int n_sysID; for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { @@ -5816,12 +5798,12 @@ test_xmlACatalogResolve(void) { pubID = gen_const_xmlChar_ptr(n_pubID, 1); sysID = gen_const_xmlChar_ptr(n_sysID, 2); - ret_val = xmlACatalogResolve(catal, (const xmlChar *)pubID, (const xmlChar *)sysID); + ret_val = xmlACatalogResolve(catal, pubID, sysID); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlCatalogPtr(n_catal, catal, 0); - des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 1); - des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 2); + des_const_xmlChar_ptr(n_pubID, pubID, 1); + des_const_xmlChar_ptr(n_sysID, sysID, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlACatalogResolve", @@ -5851,7 +5833,7 @@ test_xmlACatalogResolvePublic(void) { xmlChar * ret_val; xmlCatalogPtr catal; /* a Catalog */ int n_catal; - xmlChar * pubID; /* the public ID string */ + const xmlChar * pubID; /* the public ID string */ int n_pubID; for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { @@ -5860,11 +5842,11 @@ test_xmlACatalogResolvePublic(void) { catal = gen_xmlCatalogPtr(n_catal, 0); pubID = gen_const_xmlChar_ptr(n_pubID, 1); - ret_val = xmlACatalogResolvePublic(catal, (const xmlChar *)pubID); + ret_val = xmlACatalogResolvePublic(catal, pubID); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlCatalogPtr(n_catal, catal, 0); - des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 1); + des_const_xmlChar_ptr(n_pubID, pubID, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlACatalogResolvePublic", @@ -5892,7 +5874,7 @@ test_xmlACatalogResolveSystem(void) { xmlChar * ret_val; xmlCatalogPtr catal; /* a Catalog */ int n_catal; - xmlChar * sysID; /* the system ID string */ + const xmlChar * sysID; /* the system ID string */ int n_sysID; for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { @@ -5901,11 +5883,11 @@ test_xmlACatalogResolveSystem(void) { catal = gen_xmlCatalogPtr(n_catal, 0); sysID = gen_const_xmlChar_ptr(n_sysID, 1); - ret_val = xmlACatalogResolveSystem(catal, (const xmlChar *)sysID); + ret_val = xmlACatalogResolveSystem(catal, sysID); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlCatalogPtr(n_catal, catal, 0); - des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 1); + des_const_xmlChar_ptr(n_sysID, sysID, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlACatalogResolveSystem", @@ -5933,7 +5915,7 @@ test_xmlACatalogResolveURI(void) { xmlChar * ret_val; xmlCatalogPtr catal; /* a Catalog */ int n_catal; - xmlChar * URI; /* the URI */ + const xmlChar * URI; /* the URI */ int n_URI; for (n_catal = 0;n_catal < gen_nb_xmlCatalogPtr;n_catal++) { @@ -5942,11 +5924,11 @@ test_xmlACatalogResolveURI(void) { catal = gen_xmlCatalogPtr(n_catal, 0); URI = gen_const_xmlChar_ptr(n_URI, 1); - ret_val = xmlACatalogResolveURI(catal, (const xmlChar *)URI); + ret_val = xmlACatalogResolveURI(catal, URI); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlCatalogPtr(n_catal, catal, 0); - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 1); + des_const_xmlChar_ptr(n_URI, URI, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlACatalogResolveURI", @@ -5972,11 +5954,11 @@ test_xmlCatalogAdd(void) { #if defined(LIBXML_CATALOG_ENABLED) int mem_base; int ret_val; - xmlChar * type; /* the type of record to add to the catalog */ + const xmlChar * type; /* the type of record to add to the catalog */ int n_type; - xmlChar * orig; /* the system, public or prefix to match */ + const xmlChar * orig; /* the system, public or prefix to match */ int n_orig; - xmlChar * replace; /* the replacement value for the match */ + const xmlChar * replace; /* the replacement value for the match */ int n_replace; for (n_type = 0;n_type < gen_nb_const_xmlChar_ptr;n_type++) { @@ -5987,12 +5969,12 @@ test_xmlCatalogAdd(void) { orig = gen_const_xmlChar_ptr(n_orig, 1); replace = gen_const_xmlChar_ptr(n_replace, 2); - ret_val = xmlCatalogAdd((const xmlChar *)type, (const xmlChar *)orig, (const xmlChar *)replace); + ret_val = xmlCatalogAdd(type, orig, replace); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_type, (const xmlChar *)type, 0); - des_const_xmlChar_ptr(n_orig, (const xmlChar *)orig, 1); - des_const_xmlChar_ptr(n_replace, (const xmlChar *)replace, 2); + des_const_xmlChar_ptr(n_type, type, 0); + des_const_xmlChar_ptr(n_orig, orig, 1); + des_const_xmlChar_ptr(n_replace, replace, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCatalogAdd", @@ -6151,9 +6133,9 @@ test_xmlCatalogLocalResolve(void) { xmlChar * ret_val; void * catalogs; /* a document's list of catalogs */ int n_catalogs; - xmlChar * pubID; /* the public ID string */ + const xmlChar * pubID; /* the public ID string */ int n_pubID; - xmlChar * sysID; /* the system ID string */ + const xmlChar * sysID; /* the system ID string */ int n_sysID; for (n_catalogs = 0;n_catalogs < gen_nb_void_ptr;n_catalogs++) { @@ -6164,12 +6146,12 @@ test_xmlCatalogLocalResolve(void) { pubID = gen_const_xmlChar_ptr(n_pubID, 1); sysID = gen_const_xmlChar_ptr(n_sysID, 2); - ret_val = xmlCatalogLocalResolve(catalogs, (const xmlChar *)pubID, (const xmlChar *)sysID); + ret_val = xmlCatalogLocalResolve(catalogs, pubID, sysID); desret_xmlChar_ptr(ret_val); call_tests++; des_void_ptr(n_catalogs, catalogs, 0); - des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 1); - des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 2); + des_const_xmlChar_ptr(n_pubID, pubID, 1); + des_const_xmlChar_ptr(n_sysID, sysID, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCatalogLocalResolve", @@ -6199,7 +6181,7 @@ test_xmlCatalogLocalResolveURI(void) { xmlChar * ret_val; void * catalogs; /* a document's list of catalogs */ int n_catalogs; - xmlChar * URI; /* the URI */ + const xmlChar * URI; /* the URI */ int n_URI; for (n_catalogs = 0;n_catalogs < gen_nb_void_ptr;n_catalogs++) { @@ -6208,11 +6190,11 @@ test_xmlCatalogLocalResolveURI(void) { catalogs = gen_void_ptr(n_catalogs, 0); URI = gen_const_xmlChar_ptr(n_URI, 1); - ret_val = xmlCatalogLocalResolveURI(catalogs, (const xmlChar *)URI); + ret_val = xmlCatalogLocalResolveURI(catalogs, URI); desret_xmlChar_ptr(ret_val); call_tests++; des_void_ptr(n_catalogs, catalogs, 0); - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 1); + des_const_xmlChar_ptr(n_URI, URI, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCatalogLocalResolveURI", @@ -6237,16 +6219,16 @@ test_xmlCatalogRemove(void) { #if defined(LIBXML_CATALOG_ENABLED) int ret_val; - xmlChar * value; /* the value to remove */ + const xmlChar * value; /* the value to remove */ int n_value; for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { value = gen_const_xmlChar_ptr(n_value, 0); - ret_val = xmlCatalogRemove((const xmlChar *)value); + ret_val = xmlCatalogRemove(value); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); xmlResetLastError(); } function_tests++; @@ -6262,9 +6244,9 @@ test_xmlCatalogResolve(void) { #if defined(LIBXML_CATALOG_ENABLED) xmlChar * ret_val; - xmlChar * pubID; /* the public ID string */ + const xmlChar * pubID; /* the public ID string */ int n_pubID; - xmlChar * sysID; /* the system ID string */ + const xmlChar * sysID; /* the system ID string */ int n_sysID; for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { @@ -6272,11 +6254,11 @@ test_xmlCatalogResolve(void) { pubID = gen_const_xmlChar_ptr(n_pubID, 0); sysID = gen_const_xmlChar_ptr(n_sysID, 1); - ret_val = xmlCatalogResolve((const xmlChar *)pubID, (const xmlChar *)sysID); + ret_val = xmlCatalogResolve(pubID, sysID); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 0); - des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 1); + des_const_xmlChar_ptr(n_pubID, pubID, 0); + des_const_xmlChar_ptr(n_sysID, sysID, 1); xmlResetLastError(); } } @@ -6294,17 +6276,17 @@ test_xmlCatalogResolvePublic(void) { #if defined(LIBXML_CATALOG_ENABLED) int mem_base; xmlChar * ret_val; - xmlChar * pubID; /* the public ID string */ + const xmlChar * pubID; /* the public ID string */ int n_pubID; for (n_pubID = 0;n_pubID < gen_nb_const_xmlChar_ptr;n_pubID++) { mem_base = xmlMemBlocks(); pubID = gen_const_xmlChar_ptr(n_pubID, 0); - ret_val = xmlCatalogResolvePublic((const xmlChar *)pubID); + ret_val = xmlCatalogResolvePublic(pubID); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_pubID, (const xmlChar *)pubID, 0); + des_const_xmlChar_ptr(n_pubID, pubID, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCatalogResolvePublic", @@ -6328,17 +6310,17 @@ test_xmlCatalogResolveSystem(void) { #if defined(LIBXML_CATALOG_ENABLED) int mem_base; xmlChar * ret_val; - xmlChar * sysID; /* the system ID string */ + const xmlChar * sysID; /* the system ID string */ int n_sysID; for (n_sysID = 0;n_sysID < gen_nb_const_xmlChar_ptr;n_sysID++) { mem_base = xmlMemBlocks(); sysID = gen_const_xmlChar_ptr(n_sysID, 0); - ret_val = xmlCatalogResolveSystem((const xmlChar *)sysID); + ret_val = xmlCatalogResolveSystem(sysID); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_sysID, (const xmlChar *)sysID, 0); + des_const_xmlChar_ptr(n_sysID, sysID, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCatalogResolveSystem", @@ -6362,17 +6344,17 @@ test_xmlCatalogResolveURI(void) { #if defined(LIBXML_CATALOG_ENABLED) int mem_base; xmlChar * ret_val; - xmlChar * URI; /* the URI */ + const xmlChar * URI; /* the URI */ int n_URI; for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { mem_base = xmlMemBlocks(); URI = gen_const_xmlChar_ptr(n_URI, 0); - ret_val = xmlCatalogResolveURI((const xmlChar *)URI); + ret_val = xmlCatalogResolveURI(URI); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); + des_const_xmlChar_ptr(n_URI, URI, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCatalogResolveURI", @@ -6554,15 +6536,15 @@ test_xmlLoadCatalogs(void) { int test_ret = 0; #if defined(LIBXML_CATALOG_ENABLED) - char * pathss; /* a list of directories separated by a colon or a space. */ + const char * pathss; /* a list of directories separated by a colon or a space. */ int n_pathss; for (n_pathss = 0;n_pathss < gen_nb_const_char_ptr;n_pathss++) { pathss = gen_const_char_ptr(n_pathss, 0); - xmlLoadCatalogs((const char *)pathss); + xmlLoadCatalogs(pathss); call_tests++; - des_const_char_ptr(n_pathss, (const char *)pathss, 0); + des_const_char_ptr(n_pathss, pathss, 0); xmlResetLastError(); } function_tests++; @@ -6678,7 +6660,7 @@ test_xmlCharInRange(void) { int ret_val; unsigned int val; /* character to be validated */ int n_val; - xmlChRangeGroup * rptr; /* pointer to range to be used to validate */ + const xmlChRangeGroup * rptr; /* pointer to range to be used to validate */ int n_rptr; for (n_val = 0;n_val < gen_nb_unsigned_int;n_val++) { @@ -6687,11 +6669,11 @@ test_xmlCharInRange(void) { val = gen_unsigned_int(n_val, 0); rptr = gen_const_xmlChRangeGroup_ptr(n_rptr, 1); - ret_val = xmlCharInRange(val, (const xmlChRangeGroup *)rptr); + ret_val = xmlCharInRange(val, rptr); desret_int(ret_val); call_tests++; des_unsigned_int(n_val, val, 0); - des_const_xmlChRangeGroup_ptr(n_rptr, (const xmlChRangeGroup *)rptr, 1); + des_const_xmlChRangeGroup_ptr(n_rptr, rptr, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCharInRange", @@ -7453,7 +7435,7 @@ test_xmlDebugDumpString(void) { int mem_base; FILE * output; /* the FILE * for the output */ int n_output; - xmlChar * str; /* the string */ + const xmlChar * str; /* the string */ int n_str; for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) { @@ -7462,10 +7444,10 @@ test_xmlDebugDumpString(void) { output = gen_debug_FILE_ptr(n_output, 0); str = gen_const_xmlChar_ptr(n_str, 1); - xmlDebugDumpString(output, (const xmlChar *)str); + xmlDebugDumpString(output, str); call_tests++; des_debug_FILE_ptr(n_output, output, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlDebugDumpString", @@ -8277,7 +8259,7 @@ test_xmlDictExists(void) { const xmlChar * ret_val; xmlDictPtr dict; /* the dictionary */ int n_dict; - xmlChar * name; /* the name of the userdata */ + const xmlChar * name; /* the name of the userdata */ int n_name; int len; /* the length of the name, if -1 it is recomputed */ int n_len; @@ -8293,11 +8275,11 @@ test_xmlDictExists(void) { (len > xmlStrlen(BAD_CAST name))) len = 0; - ret_val = xmlDictExists(dict, (const xmlChar *)name, len); + ret_val = xmlDictExists(dict, name, len); desret_const_xmlChar_ptr(ret_val); call_tests++; des_xmlDictPtr(n_dict, dict, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -8336,7 +8318,7 @@ test_xmlDictLookup(void) { const xmlChar * ret_val; xmlDictPtr dict; /* dictionary */ int n_dict; - xmlChar * name; /* string key */ + const xmlChar * name; /* string key */ int n_name; int len; /* length of the key, if -1 it is recomputed */ int n_len; @@ -8352,11 +8334,11 @@ test_xmlDictLookup(void) { (len > xmlStrlen(BAD_CAST name))) len = 0; - ret_val = xmlDictLookup(dict, (const xmlChar *)name, len); + ret_val = xmlDictLookup(dict, name, len); desret_const_xmlChar_ptr(ret_val); call_tests++; des_xmlDictPtr(n_dict, dict, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -8385,7 +8367,7 @@ test_xmlDictOwns(void) { int ret_val; xmlDictPtr dict; /* the dictionary */ int n_dict; - xmlChar * str; /* the string */ + const xmlChar * str; /* the string */ int n_str; for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { @@ -8394,11 +8376,11 @@ test_xmlDictOwns(void) { dict = gen_xmlDictPtr(n_dict, 0); str = gen_const_xmlChar_ptr(n_str, 1); - ret_val = xmlDictOwns(dict, (const xmlChar *)str); + ret_val = xmlDictOwns(dict, str); desret_int(ret_val); call_tests++; des_xmlDictPtr(n_dict, dict, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlDictOwns", @@ -8424,9 +8406,9 @@ test_xmlDictQLookup(void) { const xmlChar * ret_val; xmlDictPtr dict; /* the dictionary */ int n_dict; - xmlChar * prefix; /* the prefix */ + const xmlChar * prefix; /* the prefix */ int n_prefix; - xmlChar * name; /* the name */ + const xmlChar * name; /* the name */ int n_name; for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { @@ -8437,12 +8419,12 @@ test_xmlDictQLookup(void) { prefix = gen_const_xmlChar_ptr(n_prefix, 1); name = gen_const_xmlChar_ptr(n_name, 2); - ret_val = xmlDictQLookup(dict, (const xmlChar *)prefix, (const xmlChar *)name); + ret_val = xmlDictQLookup(dict, prefix, name); desret_const_xmlChar_ptr(ret_val); call_tests++; des_xmlDictPtr(n_dict, dict, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlDictQLookup", @@ -8596,7 +8578,7 @@ test_UTF8Toisolat1(void) { int n_out; int * outlen; /* the length of @out */ int n_outlen; - unsigned char * in; /* a pointer to an array of UTF-8 chars */ + const unsigned char * in; /* a pointer to an array of UTF-8 chars */ int n_in; int * inlen; /* the length of @in */ int n_inlen; @@ -8611,12 +8593,12 @@ test_UTF8Toisolat1(void) { in = gen_const_unsigned_char_ptr(n_in, 2); inlen = gen_int_ptr(n_inlen, 3); - ret_val = UTF8Toisolat1(out, outlen, (const unsigned char *)in, inlen); + ret_val = UTF8Toisolat1(out, outlen, in, inlen); desret_int(ret_val); call_tests++; des_unsigned_char_ptr(n_out, out, 0); des_int_ptr(n_outlen, outlen, 1); - des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_const_unsigned_char_ptr(n_in, in, 2); des_int_ptr(n_inlen, inlen, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -8651,7 +8633,7 @@ test_isolat1ToUTF8(void) { int n_out; int * outlen; /* the length of @out */ int n_outlen; - unsigned char * in; /* a pointer to an array of ISO Latin 1 chars */ + const unsigned char * in; /* a pointer to an array of ISO Latin 1 chars */ int n_in; int * inlen; /* the length of @in */ int n_inlen; @@ -8666,12 +8648,12 @@ test_isolat1ToUTF8(void) { in = gen_const_unsigned_char_ptr(n_in, 2); inlen = gen_int_ptr(n_inlen, 3); - ret_val = isolat1ToUTF8(out, outlen, (const unsigned char *)in, inlen); + ret_val = isolat1ToUTF8(out, outlen, in, inlen); desret_int(ret_val); call_tests++; des_unsigned_char_ptr(n_out, out, 0); des_int_ptr(n_outlen, outlen, 1); - des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 2); + des_const_unsigned_char_ptr(n_in, in, 2); des_int_ptr(n_inlen, inlen, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -8699,9 +8681,9 @@ test_xmlAddEncodingAlias(void) { int test_ret = 0; int ret_val; - char * name; /* the encoding name as parsed, in UTF-8 format (ASCII actually) */ + const char * name; /* the encoding name as parsed, in UTF-8 format (ASCII actually) */ int n_name; - char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ + const char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ int n_alias; for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) { @@ -8709,11 +8691,11 @@ test_xmlAddEncodingAlias(void) { name = gen_const_char_ptr(n_name, 0); alias = gen_const_char_ptr(n_alias, 1); - ret_val = xmlAddEncodingAlias((const char *)name, (const char *)alias); + ret_val = xmlAddEncodingAlias(name, alias); desret_int(ret_val); call_tests++; - des_const_char_ptr(n_name, (const char *)name, 0); - des_const_char_ptr(n_alias, (const char *)alias, 1); + des_const_char_ptr(n_name, name, 0); + des_const_char_ptr(n_alias, alias, 1); xmlResetLastError(); } } @@ -8941,17 +8923,17 @@ test_xmlDelEncodingAlias(void) { int mem_base; int ret_val; - char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ + const char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ int n_alias; for (n_alias = 0;n_alias < gen_nb_const_char_ptr;n_alias++) { mem_base = xmlMemBlocks(); alias = gen_const_char_ptr(n_alias, 0); - ret_val = xmlDelEncodingAlias((const char *)alias); + ret_val = xmlDelEncodingAlias(alias); desret_int(ret_val); call_tests++; - des_const_char_ptr(n_alias, (const char *)alias, 0); + des_const_char_ptr(n_alias, alias, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlDelEncodingAlias", @@ -8973,7 +8955,7 @@ test_xmlDetectCharEncoding(void) { int mem_base; xmlCharEncoding ret_val; - unsigned char * in; /* a pointer to the first bytes of the XML entity, must be at least 2 bytes long (at least 4 if encoding is UTF4 variant). */ + const unsigned char * in; /* a pointer to the first bytes of the XML entity, must be at least 2 bytes long (at least 4 if encoding is UTF4 variant). */ int n_in; int len; /* pointer to the length of the buffer */ int n_len; @@ -8984,10 +8966,10 @@ test_xmlDetectCharEncoding(void) { in = gen_const_unsigned_char_ptr(n_in, 0); len = gen_int(n_len, 1); - ret_val = xmlDetectCharEncoding((const unsigned char *)in, len); + ret_val = xmlDetectCharEncoding(in, len); desret_xmlCharEncoding(ret_val); call_tests++; - des_const_unsigned_char_ptr(n_in, (const unsigned char *)in, 0); + des_const_unsigned_char_ptr(n_in, in, 0); des_int(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -9064,17 +9046,17 @@ test_xmlGetEncodingAlias(void) { int mem_base; const char * ret_val; - char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ + const char * alias; /* the alias name as parsed, in UTF-8 format (ASCII actually) */ int n_alias; for (n_alias = 0;n_alias < gen_nb_const_char_ptr;n_alias++) { mem_base = xmlMemBlocks(); alias = gen_const_char_ptr(n_alias, 0); - ret_val = xmlGetEncodingAlias((const char *)alias); + ret_val = xmlGetEncodingAlias(alias); desret_const_char_ptr(ret_val); call_tests++; - des_const_char_ptr(n_alias, (const char *)alias, 0); + des_const_char_ptr(n_alias, alias, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetEncodingAlias", @@ -9121,17 +9103,17 @@ test_xmlParseCharEncoding(void) { int mem_base; xmlCharEncoding ret_val; - char * name; /* the encoding name as parsed, in UTF-8 format (ASCII actually) */ + const char * name; /* the encoding name as parsed, in UTF-8 format (ASCII actually) */ int n_name; for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) { mem_base = xmlMemBlocks(); name = gen_const_char_ptr(n_name, 0); - ret_val = xmlParseCharEncoding((const char *)name); + ret_val = xmlParseCharEncoding(name); desret_xmlCharEncoding(ret_val); call_tests++; - des_const_char_ptr(n_name, (const char *)name, 0); + des_const_char_ptr(n_name, name, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParseCharEncoding", @@ -9218,15 +9200,15 @@ test_xmlAddDocEntity(void) { xmlEntityPtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; int type; /* the entity type XML_xxx_yyy_ENTITY */ int n_type; - xmlChar * ExternalID; /* the entity external ID if available */ + const xmlChar * ExternalID; /* the entity external ID if available */ int n_ExternalID; - xmlChar * SystemID; /* the entity system ID if available */ + const xmlChar * SystemID; /* the entity system ID if available */ int n_SystemID; - xmlChar * content; /* the entity content */ + const xmlChar * content; /* the entity content */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -9243,15 +9225,15 @@ test_xmlAddDocEntity(void) { SystemID = gen_const_xmlChar_ptr(n_SystemID, 4); content = gen_const_xmlChar_ptr(n_content, 5); - ret_val = xmlAddDocEntity(doc, (const xmlChar *)name, type, (const xmlChar *)ExternalID, (const xmlChar *)SystemID, (const xmlChar *)content); + ret_val = xmlAddDocEntity(doc, name, type, ExternalID, SystemID, content); desret_xmlEntityPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_int(n_type, type, 2); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 3); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 4); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 5); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 3); + des_const_xmlChar_ptr(n_SystemID, SystemID, 4); + des_const_xmlChar_ptr(n_content, content, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlAddDocEntity", @@ -9285,15 +9267,15 @@ test_xmlAddDtdEntity(void) { xmlEntityPtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; int type; /* the entity type XML_xxx_yyy_ENTITY */ int n_type; - xmlChar * ExternalID; /* the entity external ID if available */ + const xmlChar * ExternalID; /* the entity external ID if available */ int n_ExternalID; - xmlChar * SystemID; /* the entity system ID if available */ + const xmlChar * SystemID; /* the entity system ID if available */ int n_SystemID; - xmlChar * content; /* the entity content */ + const xmlChar * content; /* the entity content */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -9310,15 +9292,15 @@ test_xmlAddDtdEntity(void) { SystemID = gen_const_xmlChar_ptr(n_SystemID, 4); content = gen_const_xmlChar_ptr(n_content, 5); - ret_val = xmlAddDtdEntity(doc, (const xmlChar *)name, type, (const xmlChar *)ExternalID, (const xmlChar *)SystemID, (const xmlChar *)content); + ret_val = xmlAddDtdEntity(doc, name, type, ExternalID, SystemID, content); desret_xmlEntityPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_int(n_type, type, 2); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 3); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 4); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 5); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 3); + des_const_xmlChar_ptr(n_SystemID, SystemID, 4); + des_const_xmlChar_ptr(n_content, content, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlAddDtdEntity", @@ -9458,7 +9440,7 @@ test_xmlEncodeEntitiesReentrant(void) { xmlChar * ret_val; xmlDocPtr doc; /* the document containing the string */ int n_doc; - xmlChar * input; /* A string to convert to XML. */ + const xmlChar * input; /* A string to convert to XML. */ int n_input; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -9467,11 +9449,11 @@ test_xmlEncodeEntitiesReentrant(void) { doc = gen_xmlDocPtr(n_doc, 0); input = gen_const_xmlChar_ptr(n_input, 1); - ret_val = xmlEncodeEntitiesReentrant(doc, (const xmlChar *)input); + ret_val = xmlEncodeEntitiesReentrant(doc, input); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_input, (const xmlChar *)input, 1); + des_const_xmlChar_ptr(n_input, input, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlEncodeEntitiesReentrant", @@ -9499,9 +9481,9 @@ test_xmlEncodeSpecialChars(void) { int mem_base; xmlChar * ret_val; - xmlDoc * doc; /* the document containing the string */ + const xmlDoc * doc; /* the document containing the string */ int n_doc; - xmlChar * input; /* A string to convert to XML. */ + const xmlChar * input; /* A string to convert to XML. */ int n_input; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -9510,11 +9492,11 @@ test_xmlEncodeSpecialChars(void) { doc = gen_const_xmlDoc_ptr(n_doc, 0); input = gen_const_xmlChar_ptr(n_input, 1); - ret_val = xmlEncodeSpecialChars((const xmlDoc *)doc, (const xmlChar *)input); + ret_val = xmlEncodeSpecialChars(doc, input); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlChar_ptr(n_input, (const xmlChar *)input, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_input, input, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlEncodeSpecialChars", @@ -9538,9 +9520,9 @@ test_xmlGetDocEntity(void) { int mem_base; xmlEntityPtr ret_val; - xmlDoc * doc; /* the document referencing the entity */ + const xmlDoc * doc; /* the document referencing the entity */ int n_doc; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -9549,11 +9531,11 @@ test_xmlGetDocEntity(void) { doc = gen_const_xmlDoc_ptr(n_doc, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlGetDocEntity((const xmlDoc *)doc, (const xmlChar *)name); + ret_val = xmlGetDocEntity(doc, name); desret_xmlEntityPtr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetDocEntity", @@ -9579,7 +9561,7 @@ test_xmlGetDtdEntity(void) { xmlEntityPtr ret_val; xmlDocPtr doc; /* the document referencing the entity */ int n_doc; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -9588,11 +9570,11 @@ test_xmlGetDtdEntity(void) { doc = gen_xmlDocPtr(n_doc, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlGetDtdEntity(doc, (const xmlChar *)name); + ret_val = xmlGetDtdEntity(doc, name); desret_xmlEntityPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetDtdEntity", @@ -9618,7 +9600,7 @@ test_xmlGetParameterEntity(void) { xmlEntityPtr ret_val; xmlDocPtr doc; /* the document referencing the entity */ int n_doc; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -9627,11 +9609,11 @@ test_xmlGetParameterEntity(void) { doc = gen_xmlDocPtr(n_doc, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlGetParameterEntity(doc, (const xmlChar *)name); + ret_val = xmlGetParameterEntity(doc, name); desret_xmlEntityPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetParameterEntity", @@ -9655,17 +9637,17 @@ test_xmlGetPredefinedEntity(void) { int mem_base; xmlEntityPtr ret_val; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { mem_base = xmlMemBlocks(); name = gen_const_xmlChar_ptr(n_name, 0); - ret_val = xmlGetPredefinedEntity((const xmlChar *)name); + ret_val = xmlGetPredefinedEntity(name); desret_xmlEntityPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetPredefinedEntity", @@ -9689,15 +9671,15 @@ test_xmlNewEntity(void) { xmlEntityPtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; int type; /* the entity type XML_xxx_yyy_ENTITY */ int n_type; - xmlChar * ExternalID; /* the entity external ID if available */ + const xmlChar * ExternalID; /* the entity external ID if available */ int n_ExternalID; - xmlChar * SystemID; /* the entity system ID if available */ + const xmlChar * SystemID; /* the entity system ID if available */ int n_SystemID; - xmlChar * content; /* the entity content */ + const xmlChar * content; /* the entity content */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -9714,15 +9696,15 @@ test_xmlNewEntity(void) { SystemID = gen_const_xmlChar_ptr(n_SystemID, 4); content = gen_const_xmlChar_ptr(n_content, 5); - ret_val = xmlNewEntity(doc, (const xmlChar *)name, type, (const xmlChar *)ExternalID, (const xmlChar *)SystemID, (const xmlChar *)content); + ret_val = xmlNewEntity(doc, name, type, ExternalID, SystemID, content); desret_xmlEntityPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_int(n_type, type, 2); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 3); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 4); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 5); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 3); + des_const_xmlChar_ptr(n_SystemID, SystemID, 4); + des_const_xmlChar_ptr(n_content, content, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewEntity", @@ -9779,7 +9761,7 @@ test_xmlHashAddEntry(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* string key */ + const xmlChar * key; /* string key */ int n_key; void * payload; /* pointer to the payload */ int n_payload; @@ -9792,11 +9774,11 @@ test_xmlHashAddEntry(void) { key = gen_const_xmlChar_ptr(n_key, 1); payload = gen_void_ptr(n_payload, 2); - ret_val = xmlHashAddEntry(hash, (const xmlChar *)key, payload); + ret_val = xmlHashAddEntry(hash, key, payload); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); + des_const_xmlChar_ptr(n_key, key, 1); des_void_ptr(n_payload, payload, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -9825,9 +9807,9 @@ test_xmlHashAddEntry2(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; void * payload; /* pointer to the payload */ int n_payload; @@ -9842,12 +9824,12 @@ test_xmlHashAddEntry2(void) { key2 = gen_const_xmlChar_ptr(n_key2, 2); payload = gen_void_ptr(n_payload, 3); - ret_val = xmlHashAddEntry2(hash, (const xmlChar *)key, (const xmlChar *)key2, payload); + ret_val = xmlHashAddEntry2(hash, key, key2, payload); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); des_void_ptr(n_payload, payload, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -9878,11 +9860,11 @@ test_xmlHashAddEntry3(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; - xmlChar * key3; /* third string key */ + const xmlChar * key3; /* third string key */ int n_key3; void * payload; /* pointer to the payload */ int n_payload; @@ -9899,13 +9881,13 @@ test_xmlHashAddEntry3(void) { key3 = gen_const_xmlChar_ptr(n_key3, 3); payload = gen_void_ptr(n_payload, 4); - ret_val = xmlHashAddEntry3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3, payload); + ret_val = xmlHashAddEntry3(hash, key, key2, key3, payload); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); - des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); + des_const_xmlChar_ptr(n_key3, key3, 3); des_void_ptr(n_payload, payload, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -9967,7 +9949,7 @@ test_xmlHashDefaultDeallocator(void) { int mem_base; void * entry; /* hash table entry */ int n_entry; - xmlChar * key; /* the entry's string key */ + const xmlChar * key; /* the entry's string key */ int n_key; for (n_entry = 0;n_entry < gen_nb_void_ptr;n_entry++) { @@ -9976,10 +9958,10 @@ test_xmlHashDefaultDeallocator(void) { entry = gen_void_ptr(n_entry, 0); key = gen_const_xmlChar_ptr(n_key, 1); - xmlHashDefaultDeallocator(entry, (const xmlChar *)key); + xmlHashDefaultDeallocator(entry, key); call_tests++; des_void_ptr(n_entry, entry, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); + des_const_xmlChar_ptr(n_key, key, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHashDefaultDeallocator", @@ -10005,7 +9987,7 @@ test_xmlHashLookup(void) { void * ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* string key */ + const xmlChar * key; /* string key */ int n_key; for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { @@ -10014,11 +9996,11 @@ test_xmlHashLookup(void) { hash = gen_xmlHashTablePtr(n_hash, 0); key = gen_const_xmlChar_ptr(n_key, 1); - ret_val = xmlHashLookup(hash, (const xmlChar *)key); + ret_val = xmlHashLookup(hash, key); desret_void_ptr(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); + des_const_xmlChar_ptr(n_key, key, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHashLookup", @@ -10044,9 +10026,9 @@ test_xmlHashLookup2(void) { void * ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { @@ -10057,12 +10039,12 @@ test_xmlHashLookup2(void) { key = gen_const_xmlChar_ptr(n_key, 1); key2 = gen_const_xmlChar_ptr(n_key2, 2); - ret_val = xmlHashLookup2(hash, (const xmlChar *)key, (const xmlChar *)key2); + ret_val = xmlHashLookup2(hash, key, key2); desret_void_ptr(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHashLookup2", @@ -10090,11 +10072,11 @@ test_xmlHashLookup3(void) { void * ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; - xmlChar * key3; /* third string key */ + const xmlChar * key3; /* third string key */ int n_key3; for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { @@ -10107,13 +10089,13 @@ test_xmlHashLookup3(void) { key2 = gen_const_xmlChar_ptr(n_key2, 2); key3 = gen_const_xmlChar_ptr(n_key3, 3); - ret_val = xmlHashLookup3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3); + ret_val = xmlHashLookup3(hash, key, key2, key3); desret_void_ptr(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); - des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); + des_const_xmlChar_ptr(n_key3, key3, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHashLookup3", @@ -10143,9 +10125,9 @@ test_xmlHashQLookup(void) { void * ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * prefix; /* prefix of the string key */ + const xmlChar * prefix; /* prefix of the string key */ int n_prefix; - xmlChar * name; /* local name of the string key */ + const xmlChar * name; /* local name of the string key */ int n_name; for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { @@ -10156,12 +10138,12 @@ test_xmlHashQLookup(void) { prefix = gen_const_xmlChar_ptr(n_prefix, 1); name = gen_const_xmlChar_ptr(n_name, 2); - ret_val = xmlHashQLookup(hash, (const xmlChar *)prefix, (const xmlChar *)name); + ret_val = xmlHashQLookup(hash, prefix, name); desret_void_ptr(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHashQLookup", @@ -10189,13 +10171,13 @@ test_xmlHashQLookup2(void) { void * ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * prefix; /* first prefix */ + const xmlChar * prefix; /* first prefix */ int n_prefix; - xmlChar * name; /* first local name */ + const xmlChar * name; /* first local name */ int n_name; - xmlChar * prefix2; /* second prefix */ + const xmlChar * prefix2; /* second prefix */ int n_prefix2; - xmlChar * name2; /* second local name */ + const xmlChar * name2; /* second local name */ int n_name2; for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { @@ -10210,14 +10192,14 @@ test_xmlHashQLookup2(void) { prefix2 = gen_const_xmlChar_ptr(n_prefix2, 3); name2 = gen_const_xmlChar_ptr(n_name2, 4); - ret_val = xmlHashQLookup2(hash, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2); + ret_val = xmlHashQLookup2(hash, prefix, name, prefix2, name2); desret_void_ptr(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_prefix2, (const xmlChar *)prefix2, 3); - des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 4); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_prefix2, prefix2, 3); + des_const_xmlChar_ptr(n_name2, name2, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHashQLookup2", @@ -10249,17 +10231,17 @@ test_xmlHashQLookup3(void) { void * ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * prefix; /* first prefix */ + const xmlChar * prefix; /* first prefix */ int n_prefix; - xmlChar * name; /* first local name */ + const xmlChar * name; /* first local name */ int n_name; - xmlChar * prefix2; /* second prefix */ + const xmlChar * prefix2; /* second prefix */ int n_prefix2; - xmlChar * name2; /* second local name */ + const xmlChar * name2; /* second local name */ int n_name2; - xmlChar * prefix3; /* third prefix */ + const xmlChar * prefix3; /* third prefix */ int n_prefix3; - xmlChar * name3; /* third local name */ + const xmlChar * name3; /* third local name */ int n_name3; for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { @@ -10278,16 +10260,16 @@ test_xmlHashQLookup3(void) { prefix3 = gen_const_xmlChar_ptr(n_prefix3, 5); name3 = gen_const_xmlChar_ptr(n_name3, 6); - ret_val = xmlHashQLookup3(hash, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)prefix2, (const xmlChar *)name2, (const xmlChar *)prefix3, (const xmlChar *)name3); + ret_val = xmlHashQLookup3(hash, prefix, name, prefix2, name2, prefix3, name3); desret_void_ptr(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_prefix2, (const xmlChar *)prefix2, 3); - des_const_xmlChar_ptr(n_name2, (const xmlChar *)name2, 4); - des_const_xmlChar_ptr(n_prefix3, (const xmlChar *)prefix3, 5); - des_const_xmlChar_ptr(n_name3, (const xmlChar *)name3, 6); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_prefix2, prefix2, 3); + des_const_xmlChar_ptr(n_name2, name2, 4); + des_const_xmlChar_ptr(n_prefix3, prefix3, 5); + des_const_xmlChar_ptr(n_name3, name3, 6); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHashQLookup3", @@ -10323,7 +10305,7 @@ test_xmlHashRemoveEntry(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* string key */ + const xmlChar * key; /* string key */ int n_key; xmlHashDeallocator dealloc; /* deallocator function for removed item or NULL */ int n_dealloc; @@ -10336,11 +10318,11 @@ test_xmlHashRemoveEntry(void) { key = gen_const_xmlChar_ptr(n_key, 1); dealloc = gen_xmlHashDeallocator(n_dealloc, 2); - ret_val = xmlHashRemoveEntry(hash, (const xmlChar *)key, dealloc); + ret_val = xmlHashRemoveEntry(hash, key, dealloc); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); + des_const_xmlChar_ptr(n_key, key, 1); des_xmlHashDeallocator(n_dealloc, dealloc, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -10369,9 +10351,9 @@ test_xmlHashRemoveEntry2(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; xmlHashDeallocator dealloc; /* deallocator function for removed item or NULL */ int n_dealloc; @@ -10386,12 +10368,12 @@ test_xmlHashRemoveEntry2(void) { key2 = gen_const_xmlChar_ptr(n_key2, 2); dealloc = gen_xmlHashDeallocator(n_dealloc, 3); - ret_val = xmlHashRemoveEntry2(hash, (const xmlChar *)key, (const xmlChar *)key2, dealloc); + ret_val = xmlHashRemoveEntry2(hash, key, key2, dealloc); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); des_xmlHashDeallocator(n_dealloc, dealloc, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -10422,11 +10404,11 @@ test_xmlHashRemoveEntry3(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; - xmlChar * key3; /* third string key */ + const xmlChar * key3; /* third string key */ int n_key3; xmlHashDeallocator dealloc; /* deallocator function for removed item or NULL */ int n_dealloc; @@ -10443,13 +10425,13 @@ test_xmlHashRemoveEntry3(void) { key3 = gen_const_xmlChar_ptr(n_key3, 3); dealloc = gen_xmlHashDeallocator(n_dealloc, 4); - ret_val = xmlHashRemoveEntry3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3, dealloc); + ret_val = xmlHashRemoveEntry3(hash, key, key2, key3, dealloc); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); - des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); + des_const_xmlChar_ptr(n_key3, key3, 3); des_xmlHashDeallocator(n_dealloc, dealloc, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -10554,7 +10536,7 @@ test_xmlHashUpdateEntry(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* string key */ + const xmlChar * key; /* string key */ int n_key; void * payload; /* pointer to the payload */ int n_payload; @@ -10571,11 +10553,11 @@ test_xmlHashUpdateEntry(void) { payload = gen_void_ptr(n_payload, 2); dealloc = gen_xmlHashDeallocator(n_dealloc, 3); - ret_val = xmlHashUpdateEntry(hash, (const xmlChar *)key, payload, dealloc); + ret_val = xmlHashUpdateEntry(hash, key, payload, dealloc); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); + des_const_xmlChar_ptr(n_key, key, 1); des_void_ptr(n_payload, payload, 2); des_xmlHashDeallocator(n_dealloc, dealloc, 3); xmlResetLastError(); @@ -10607,9 +10589,9 @@ test_xmlHashUpdateEntry2(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; void * payload; /* pointer to the payload */ int n_payload; @@ -10628,12 +10610,12 @@ test_xmlHashUpdateEntry2(void) { payload = gen_void_ptr(n_payload, 3); dealloc = gen_xmlHashDeallocator(n_dealloc, 4); - ret_val = xmlHashUpdateEntry2(hash, (const xmlChar *)key, (const xmlChar *)key2, payload, dealloc); + ret_val = xmlHashUpdateEntry2(hash, key, key2, payload, dealloc); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); des_void_ptr(n_payload, payload, 3); des_xmlHashDeallocator(n_dealloc, dealloc, 4); xmlResetLastError(); @@ -10667,11 +10649,11 @@ test_xmlHashUpdateEntry3(void) { int ret_val; xmlHashTablePtr hash; /* hash table */ int n_hash; - xmlChar * key; /* first string key */ + const xmlChar * key; /* first string key */ int n_key; - xmlChar * key2; /* second string key */ + const xmlChar * key2; /* second string key */ int n_key2; - xmlChar * key3; /* third string key */ + const xmlChar * key3; /* third string key */ int n_key3; void * payload; /* pointer to the payload */ int n_payload; @@ -10692,13 +10674,13 @@ test_xmlHashUpdateEntry3(void) { payload = gen_void_ptr(n_payload, 4); dealloc = gen_xmlHashDeallocator(n_dealloc, 5); - ret_val = xmlHashUpdateEntry3(hash, (const xmlChar *)key, (const xmlChar *)key2, (const xmlChar *)key3, payload, dealloc); + ret_val = xmlHashUpdateEntry3(hash, key, key2, key3, payload, dealloc); desret_int(ret_val); call_tests++; des_xmlHashTablePtr(n_hash, hash, 0); - des_const_xmlChar_ptr(n_key, (const xmlChar *)key, 1); - des_const_xmlChar_ptr(n_key2, (const xmlChar *)key2, 2); - des_const_xmlChar_ptr(n_key3, (const xmlChar *)key3, 3); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); + des_const_xmlChar_ptr(n_key3, key3, 3); des_void_ptr(n_payload, payload, 4); des_xmlHashDeallocator(n_dealloc, dealloc, 5); xmlResetLastError(); @@ -10865,10 +10847,6 @@ test_xmlListClear(void) { } -#define gen_nb_const_xmlListPtr 1 -#define gen_const_xmlListPtr(no, nr) NULL -#define des_const_xmlListPtr(no, val, nr) - static int test_xmlListCopy(void) { int test_ret = 0; @@ -10881,16 +10859,16 @@ test_xmlListCopy(void) { int n_old; for (n_cur = 0;n_cur < gen_nb_xmlListPtr;n_cur++) { - for (n_old = 0;n_old < gen_nb_const_xmlListPtr;n_old++) { + for (n_old = 0;n_old < gen_nb_xmlListPtr;n_old++) { mem_base = xmlMemBlocks(); cur = gen_xmlListPtr(n_cur, 0); - old = gen_const_xmlListPtr(n_old, 1); + old = gen_xmlListPtr(n_old, 1); ret_val = xmlListCopy(cur, old); desret_int(ret_val); call_tests++; des_xmlListPtr(n_cur, cur, 0); - des_const_xmlListPtr(n_old, old, 1); + des_xmlListPtr(n_old, old, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlListCopy", @@ -12141,17 +12119,17 @@ test_xmlCreateDocParserCtxt(void) { int mem_base; xmlParserCtxtPtr ret_val; - xmlChar * str; /* a pointer to an array of xmlChar */ + const xmlChar * str; /* a pointer to an array of xmlChar */ int n_str; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { mem_base = xmlMemBlocks(); str = gen_const_xmlChar_ptr(n_str, 0); - ret_val = xmlCreateDocParserCtxt((const xmlChar *)str); + ret_val = xmlCreateDocParserCtxt(str); desret_xmlParserCtxtPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCreateDocParserCtxt", @@ -12178,7 +12156,7 @@ test_xmlCreatePushParserCtxt(void) { int n_sax; void * user_data; /* The user data returned on SAX callbacks */ int n_user_data; - char * chunk; /* a pointer to an array of chars */ + const char * chunk; /* a pointer to an array of chars */ int n_chunk; int size; /* number of chars in the array */ int n_size; @@ -12200,12 +12178,12 @@ test_xmlCreatePushParserCtxt(void) { (size > xmlStrlen(BAD_CAST chunk))) size = 0; - ret_val = xmlCreatePushParserCtxt(sax, user_data, (const char *)chunk, size, filename); + ret_val = xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename); desret_xmlParserCtxtPtr(ret_val); call_tests++; des_xmlSAXHandlerPtr(n_sax, sax, 0); des_userdata(n_user_data, user_data, 1); - des_const_char_ptr(n_chunk, (const char *)chunk, 2); + des_const_char_ptr(n_chunk, chunk, 2); des_int(n_size, size, 3); des_fileoutput(n_filename, filename, 4); xmlResetLastError(); @@ -12240,11 +12218,11 @@ test_xmlCtxtReadDoc(void) { xmlDocPtr ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - xmlChar * str; /* a pointer to a zero terminated string */ + const xmlChar * str; /* a pointer to a zero terminated string */ int n_str; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -12261,13 +12239,13 @@ test_xmlCtxtReadDoc(void) { encoding = gen_const_char_ptr(n_encoding, 3); options = gen_parseroptions(n_options, 4); - ret_val = xmlCtxtReadDoc(ctxt, (const xmlChar *)str, URL, (const char *)encoding, options); + ret_val = xmlCtxtReadDoc(ctxt, str, URL, encoding, options); desret_xmlDocPtr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); des_filepath(n_URL, URL, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_parseroptions(n_options, options, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -12302,7 +12280,7 @@ test_xmlCtxtReadFile(void) { int n_ctxt; const char * filename; /* a file or URL */ int n_filename; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -12317,12 +12295,12 @@ test_xmlCtxtReadFile(void) { encoding = gen_const_char_ptr(n_encoding, 2); options = gen_parseroptions(n_options, 3); - ret_val = xmlCtxtReadFile(ctxt, filename, (const char *)encoding, options); + ret_val = xmlCtxtReadFile(ctxt, filename, encoding, options); desret_xmlDocPtr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); des_filepath(n_filename, filename, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_parseroptions(n_options, options, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -12353,13 +12331,13 @@ test_xmlCtxtReadMemory(void) { xmlDocPtr ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -12381,14 +12359,14 @@ test_xmlCtxtReadMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlCtxtReadMemory(ctxt, (const char *)buffer, size, URL, (const char *)encoding, options); + ret_val = xmlCtxtReadMemory(ctxt, buffer, size, URL, encoding, options); desret_xmlDocPtr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_const_char_ptr(n_buffer, buffer, 1); des_int(n_size, size, 2); des_filepath(n_URL, URL, 3); - des_const_char_ptr(n_encoding, (const char *)encoding, 4); + des_const_char_ptr(n_encoding, encoding, 4); des_parseroptions(n_options, options, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -12453,13 +12431,13 @@ test_xmlCtxtResetPush(void) { int ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - char * chunk; /* a pointer to an array of chars */ + const char * chunk; /* a pointer to an array of chars */ int n_chunk; int size; /* number of chars in the array */ int n_size; const char * filename; /* an optional file name or URI */ int n_filename; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { @@ -12477,14 +12455,14 @@ test_xmlCtxtResetPush(void) { (size > xmlStrlen(BAD_CAST chunk))) size = 0; - ret_val = xmlCtxtResetPush(ctxt, (const char *)chunk, size, filename, (const char *)encoding); + ret_val = xmlCtxtResetPush(ctxt, chunk, size, filename, encoding); desret_int(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_char_ptr(n_chunk, (const char *)chunk, 1); + des_const_char_ptr(n_chunk, chunk, 1); des_int(n_size, size, 2); des_filepath(n_filename, filename, 3); - des_const_char_ptr(n_encoding, (const char *)encoding, 4); + des_const_char_ptr(n_encoding, encoding, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCtxtResetPush", @@ -12796,7 +12774,7 @@ test_xmlLoadExternalEntity(void) { xmlParserInputPtr ret_val; const char * URL; /* the URL for the entity to load */ int n_URL; - char * ID; /* the Public ID for the entity to load */ + const char * ID; /* the Public ID for the entity to load */ int n_ID; xmlParserCtxtPtr ctxt; /* the context in which the entity is called or NULL */ int n_ctxt; @@ -12809,11 +12787,11 @@ test_xmlLoadExternalEntity(void) { ID = gen_const_char_ptr(n_ID, 1); ctxt = gen_xmlParserCtxtPtr(n_ctxt, 2); - ret_val = xmlLoadExternalEntity(URL, (const char *)ID, ctxt); + ret_val = xmlLoadExternalEntity(URL, ID, ctxt); desret_xmlParserInputPtr(ret_val); call_tests++; des_filepath(n_URL, URL, 0); - des_const_char_ptr(n_ID, (const char *)ID, 1); + des_const_char_ptr(n_ID, ID, 1); des_xmlParserCtxtPtr(n_ctxt, ctxt, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -12916,7 +12894,7 @@ test_xmlNewSAXParserCtxt(void) { int mem_base; xmlParserCtxtPtr ret_val; - xmlSAXHandler * sax; /* SAX handler */ + const xmlSAXHandler * sax; /* SAX handler */ int n_sax; void * userData; /* user data */ int n_userData; @@ -12927,10 +12905,10 @@ test_xmlNewSAXParserCtxt(void) { sax = gen_const_xmlSAXHandler_ptr(n_sax, 0); userData = gen_userdata(n_userData, 1); - ret_val = xmlNewSAXParserCtxt((const xmlSAXHandler *)sax, userData); + ret_val = xmlNewSAXParserCtxt(sax, userData); desret_xmlParserCtxtPtr(ret_val); call_tests++; - des_const_xmlSAXHandler_ptr(n_sax, (const xmlSAXHandler *)sax, 0); + des_const_xmlSAXHandler_ptr(n_sax, sax, 0); des_userdata(n_userData, userData, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -12969,7 +12947,7 @@ test_xmlParseBalancedChunkMemory(void) { int n_user_data; int depth; /* Used for loop detection, use 0 */ int n_depth; - xmlChar * string; /* the input string in UTF8 or ISO-Latin (zero terminated) */ + const xmlChar * string; /* the input string in UTF8 or ISO-Latin (zero terminated) */ int n_string; xmlNodePtr * lst; /* the return value for the set of parsed nodes */ int n_lst; @@ -12993,14 +12971,14 @@ test_xmlParseBalancedChunkMemory(void) { #endif - ret_val = xmlParseBalancedChunkMemory(doc, sax, user_data, depth, (const xmlChar *)string, lst); + ret_val = xmlParseBalancedChunkMemory(doc, sax, user_data, depth, string, lst); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlSAXHandlerPtr(n_sax, sax, 1); des_userdata(n_user_data, user_data, 2); des_int(n_depth, depth, 3); - des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 4); + des_const_xmlChar_ptr(n_string, string, 4); des_xmlNodePtr_ptr(n_lst, lst, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -13045,7 +13023,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) { int n_user_data; int depth; /* Used for loop detection, use 0 */ int n_depth; - xmlChar * string; /* the input string in UTF8 or ISO-Latin (zero terminated) */ + const xmlChar * string; /* the input string in UTF8 or ISO-Latin (zero terminated) */ int n_string; xmlNodePtr * lst; /* the return value for the set of parsed nodes */ int n_lst; @@ -13073,14 +13051,14 @@ test_xmlParseBalancedChunkMemoryRecover(void) { #endif - ret_val = xmlParseBalancedChunkMemoryRecover(doc, sax, user_data, depth, (const xmlChar *)string, lst, recover); + ret_val = xmlParseBalancedChunkMemoryRecover(doc, sax, user_data, depth, string, lst, recover); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlSAXHandlerPtr(n_sax, sax, 1); des_userdata(n_user_data, user_data, 2); des_int(n_depth, depth, 3); - des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 4); + des_const_xmlChar_ptr(n_string, string, 4); des_xmlNodePtr_ptr(n_lst, lst, 5); des_int(n_recover, recover, 6); xmlResetLastError(); @@ -13121,7 +13099,7 @@ test_xmlParseChunk(void) { int ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - char * chunk; /* an char array */ + const char * chunk; /* an char array */ int n_chunk; int size; /* the size in byte of the chunk */ int n_size; @@ -13141,12 +13119,12 @@ test_xmlParseChunk(void) { (size > xmlStrlen(BAD_CAST chunk))) size = 0; - ret_val = xmlParseChunk(ctxt, (const char *)chunk, size, terminate); + ret_val = xmlParseChunk(ctxt, chunk, size, terminate); if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} desret_int(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_char_ptr(n_chunk, (const char *)chunk, 1); + des_const_char_ptr(n_chunk, chunk, 1); des_int(n_size, size, 2); des_int(n_terminate, terminate, 3); xmlResetLastError(); @@ -13179,9 +13157,9 @@ test_xmlParseCtxtExternalEntity(void) { int ret_val; xmlParserCtxtPtr ctx; /* the existing parsing context */ int n_ctx; - xmlChar * URL; /* the URL for the entity to load */ + const xmlChar * URL; /* the URL for the entity to load */ int n_URL; - xmlChar * ID; /* the System ID for the entity to load */ + const xmlChar * ID; /* the System ID for the entity to load */ int n_ID; xmlNodePtr * lst; /* the return value for the set of parsed nodes */ int n_lst; @@ -13196,12 +13174,12 @@ test_xmlParseCtxtExternalEntity(void) { ID = gen_const_xmlChar_ptr(n_ID, 2); lst = gen_xmlNodePtr_ptr(n_lst, 3); - ret_val = xmlParseCtxtExternalEntity(ctx, (const xmlChar *)URL, (const xmlChar *)ID, lst); + ret_val = xmlParseCtxtExternalEntity(ctx, URL, ID, lst); desret_int(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctx, ctx, 0); - des_const_xmlChar_ptr(n_URL, (const xmlChar *)URL, 1); - des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 2); + des_const_xmlChar_ptr(n_URL, URL, 1); + des_const_xmlChar_ptr(n_ID, ID, 2); des_xmlNodePtr_ptr(n_lst, lst, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -13232,9 +13210,9 @@ test_xmlParseDTD(void) { #ifdef LIBXML_VALID_ENABLED int mem_base; xmlDtdPtr ret_val; - xmlChar * ExternalID; /* a NAME* containing the External ID of the DTD */ + const xmlChar * ExternalID; /* a NAME* containing the External ID of the DTD */ int n_ExternalID; - xmlChar * SystemID; /* a NAME* containing the URL to the DTD */ + const xmlChar * SystemID; /* a NAME* containing the URL to the DTD */ int n_SystemID; for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { @@ -13243,11 +13221,11 @@ test_xmlParseDTD(void) { ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 0); SystemID = gen_const_xmlChar_ptr(n_SystemID, 1); - ret_val = xmlParseDTD((const xmlChar *)ExternalID, (const xmlChar *)SystemID); + ret_val = xmlParseDTD(ExternalID, SystemID); desret_xmlDtdPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 0); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 1); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 0); + des_const_xmlChar_ptr(n_SystemID, SystemID, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParseDTD", @@ -13275,17 +13253,17 @@ test_xmlParseDoc(void) { #ifdef LIBXML_SAX1_ENABLED int mem_base; xmlDocPtr ret_val; - xmlChar * cur; /* a pointer to an array of xmlChar */ + const xmlChar * cur; /* a pointer to an array of xmlChar */ int n_cur; for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { mem_base = xmlMemBlocks(); cur = gen_const_xmlChar_ptr(n_cur, 0); - ret_val = xmlParseDoc((const xmlChar *)cur); + ret_val = xmlParseDoc(cur); desret_xmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_xmlChar_ptr(n_cur, cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParseDoc", @@ -13421,9 +13399,9 @@ test_xmlParseExternalEntity(void) { int n_user_data; int depth; /* Used for loop detection, use 0 */ int n_depth; - xmlChar * URL; /* the URL for the entity to load */ + const xmlChar * URL; /* the URL for the entity to load */ int n_URL; - xmlChar * ID; /* the System ID for the entity to load */ + const xmlChar * ID; /* the System ID for the entity to load */ int n_ID; xmlNodePtr * lst; /* the return value for the set of parsed nodes */ int n_lst; @@ -13444,15 +13422,15 @@ test_xmlParseExternalEntity(void) { ID = gen_const_xmlChar_ptr(n_ID, 5); lst = gen_xmlNodePtr_ptr(n_lst, 6); - ret_val = xmlParseExternalEntity(doc, sax, user_data, depth, (const xmlChar *)URL, (const xmlChar *)ID, lst); + ret_val = xmlParseExternalEntity(doc, sax, user_data, depth, URL, ID, lst); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlSAXHandlerPtr(n_sax, sax, 1); des_userdata(n_user_data, user_data, 2); des_int(n_depth, depth, 3); - des_const_xmlChar_ptr(n_URL, (const xmlChar *)URL, 4); - des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 5); + des_const_xmlChar_ptr(n_URL, URL, 4); + des_const_xmlChar_ptr(n_ID, ID, 5); des_xmlNodePtr_ptr(n_lst, lst, 6); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -13527,7 +13505,7 @@ test_xmlParseInNodeContext(void) { xmlParserErrors ret_val; xmlNodePtr node; /* the context node */ int n_node; - char * data; /* the input string */ + const char * data; /* the input string */ int n_data; int datalen; /* the input string length in bytes */ int n_datalen; @@ -13548,11 +13526,11 @@ test_xmlParseInNodeContext(void) { options = gen_parseroptions(n_options, 3); lst = gen_xmlNodePtr_ptr(n_lst, 4); - ret_val = xmlParseInNodeContext(node, (const char *)data, datalen, options, lst); + ret_val = xmlParseInNodeContext(node, data, datalen, options, lst); desret_xmlParserErrors(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); - des_const_char_ptr(n_data, (const char *)data, 1); + des_const_char_ptr(n_data, data, 1); des_int(n_datalen, datalen, 2); des_parseroptions(n_options, options, 3); des_xmlNodePtr_ptr(n_lst, lst, 4); @@ -13587,7 +13565,7 @@ test_xmlParseMemory(void) { #ifdef LIBXML_SAX1_ENABLED int mem_base; xmlDocPtr ret_val; - char * buffer; /* an pointer to a char array */ + const char * buffer; /* an pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -13601,10 +13579,10 @@ test_xmlParseMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlParseMemory((const char *)buffer, size); + ret_val = xmlParseMemory(buffer, size); desret_xmlDocPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -13625,9 +13603,9 @@ test_xmlParseMemory(void) { } -#define gen_nb_const_xmlParserNodeInfoPtr 1 -#define gen_const_xmlParserNodeInfoPtr(no, nr) NULL -#define des_const_xmlParserNodeInfoPtr(no, val, nr) +#define gen_nb_xmlParserNodeInfoPtr 1 +#define gen_xmlParserNodeInfoPtr(no, nr) NULL +#define des_xmlParserNodeInfoPtr(no, val, nr) static int test_xmlParserAddNodeInfo(void) { @@ -13640,15 +13618,15 @@ test_xmlParserAddNodeInfo(void) { int n_info; for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { - for (n_info = 0;n_info < gen_nb_const_xmlParserNodeInfoPtr;n_info++) { + for (n_info = 0;n_info < gen_nb_xmlParserNodeInfoPtr;n_info++) { mem_base = xmlMemBlocks(); ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); - info = gen_const_xmlParserNodeInfoPtr(n_info, 1); + info = gen_xmlParserNodeInfoPtr(n_info, 1); xmlParserAddNodeInfo(ctxt, info); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlParserNodeInfoPtr(n_info, info, 1); + des_xmlParserNodeInfoPtr(n_info, info, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParserAddNodeInfo", @@ -13666,14 +13644,6 @@ test_xmlParserAddNodeInfo(void) { } -#define gen_nb_const_xmlParserCtxtPtr 1 -#define gen_const_xmlParserCtxtPtr(no, nr) NULL -#define des_const_xmlParserCtxtPtr(no, val, nr) - -#define gen_nb_const_xmlNodePtr 1 -#define gen_const_xmlNodePtr(no, nr) NULL -#define des_const_xmlNodePtr(no, val, nr) - static int test_xmlParserFindNodeInfo(void) { int test_ret = 0; @@ -13685,17 +13655,17 @@ test_xmlParserFindNodeInfo(void) { xmlNodePtr node; /* an XML node within the tree */ int n_node; - for (n_ctx = 0;n_ctx < gen_nb_const_xmlParserCtxtPtr;n_ctx++) { - for (n_node = 0;n_node < gen_nb_const_xmlNodePtr;n_node++) { + for (n_ctx = 0;n_ctx < gen_nb_xmlParserCtxtPtr;n_ctx++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { mem_base = xmlMemBlocks(); - ctx = gen_const_xmlParserCtxtPtr(n_ctx, 0); - node = gen_const_xmlNodePtr(n_node, 1); + ctx = gen_xmlParserCtxtPtr(n_ctx, 0); + node = gen_xmlNodePtr(n_node, 1); ret_val = xmlParserFindNodeInfo(ctx, node); desret_const_xmlParserNodeInfo_ptr(ret_val); call_tests++; - des_const_xmlParserCtxtPtr(n_ctx, ctx, 0); - des_const_xmlNodePtr(n_node, node, 1); + des_xmlParserCtxtPtr(n_ctx, ctx, 0); + des_xmlNodePtr(n_node, node, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParserFindNodeInfo", @@ -13713,10 +13683,6 @@ test_xmlParserFindNodeInfo(void) { } -#define gen_nb_const_xmlParserNodeInfoSeqPtr 1 -#define gen_const_xmlParserNodeInfoSeqPtr(no, nr) NULL -#define des_const_xmlParserNodeInfoSeqPtr(no, val, nr) - static int test_xmlParserFindNodeInfoIndex(void) { int test_ret = 0; @@ -13728,17 +13694,17 @@ test_xmlParserFindNodeInfoIndex(void) { xmlNodePtr node; /* an XML node pointer */ int n_node; - for (n_seq = 0;n_seq < gen_nb_const_xmlParserNodeInfoSeqPtr;n_seq++) { - for (n_node = 0;n_node < gen_nb_const_xmlNodePtr;n_node++) { + for (n_seq = 0;n_seq < gen_nb_xmlParserNodeInfoSeqPtr;n_seq++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { mem_base = xmlMemBlocks(); - seq = gen_const_xmlParserNodeInfoSeqPtr(n_seq, 0); - node = gen_const_xmlNodePtr(n_node, 1); + seq = gen_xmlParserNodeInfoSeqPtr(n_seq, 0); + node = gen_xmlNodePtr(n_node, 1); ret_val = xmlParserFindNodeInfoIndex(seq, node); desret_unsigned_long(ret_val); call_tests++; - des_const_xmlParserNodeInfoSeqPtr(n_seq, seq, 0); - des_const_xmlNodePtr(n_node, node, 1); + des_xmlParserNodeInfoSeqPtr(n_seq, seq, 0); + des_xmlNodePtr(n_node, node, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParserFindNodeInfoIndex", @@ -13876,11 +13842,11 @@ test_xmlReadDoc(void) { int mem_base; xmlDocPtr ret_val; - xmlChar * cur; /* a pointer to a zero terminated string */ + const xmlChar * cur; /* a pointer to a zero terminated string */ int n_cur; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -13895,12 +13861,12 @@ test_xmlReadDoc(void) { encoding = gen_const_char_ptr(n_encoding, 2); options = gen_parseroptions(n_options, 3); - ret_val = xmlReadDoc((const xmlChar *)cur, URL, (const char *)encoding, options); + ret_val = xmlReadDoc(cur, URL, encoding, options); desret_xmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_xmlChar_ptr(n_cur, cur, 0); des_filepath(n_URL, URL, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_parseroptions(n_options, options, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -13931,7 +13897,7 @@ test_xmlReadFile(void) { xmlDocPtr ret_val; const char * filename; /* a file or URL */ int n_filename; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -13944,11 +13910,11 @@ test_xmlReadFile(void) { encoding = gen_const_char_ptr(n_encoding, 1); options = gen_parseroptions(n_options, 2); - ret_val = xmlReadFile(filename, (const char *)encoding, options); + ret_val = xmlReadFile(filename, encoding, options); desret_xmlDocPtr(ret_val); call_tests++; des_filepath(n_filename, filename, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_char_ptr(n_encoding, encoding, 1); des_parseroptions(n_options, options, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -13975,13 +13941,13 @@ test_xmlReadMemory(void) { int mem_base; xmlDocPtr ret_val; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -14001,13 +13967,13 @@ test_xmlReadMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlReadMemory((const char *)buffer, size, URL, (const char *)encoding, options); + ret_val = xmlReadMemory(buffer, size, URL, encoding, options); desret_xmlDocPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); des_filepath(n_URL, URL, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_parseroptions(n_options, options, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -14040,17 +14006,17 @@ test_xmlRecoverDoc(void) { #ifdef LIBXML_SAX1_ENABLED int mem_base; xmlDocPtr ret_val; - xmlChar * cur; /* a pointer to an array of xmlChar */ + const xmlChar * cur; /* a pointer to an array of xmlChar */ int n_cur; for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { mem_base = xmlMemBlocks(); cur = gen_const_xmlChar_ptr(n_cur, 0); - ret_val = xmlRecoverDoc((const xmlChar *)cur); + ret_val = xmlRecoverDoc(cur); desret_xmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_xmlChar_ptr(n_cur, cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlRecoverDoc", @@ -14112,7 +14078,7 @@ test_xmlRecoverMemory(void) { #ifdef LIBXML_SAX1_ENABLED int mem_base; xmlDocPtr ret_val; - char * buffer; /* an pointer to a char array */ + const char * buffer; /* an pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -14126,10 +14092,10 @@ test_xmlRecoverMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlRecoverMemory((const char *)buffer, size); + ret_val = xmlRecoverMemory(buffer, size); desret_xmlDocPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -14160,9 +14126,9 @@ test_xmlSAXParseDTD(void) { xmlDtdPtr ret_val; xmlSAXHandlerPtr sax; /* the SAX handler block */ int n_sax; - xmlChar * ExternalID; /* a NAME* containing the External ID of the DTD */ + const xmlChar * ExternalID; /* a NAME* containing the External ID of the DTD */ int n_ExternalID; - xmlChar * SystemID; /* a NAME* containing the URL to the DTD */ + const xmlChar * SystemID; /* a NAME* containing the URL to the DTD */ int n_SystemID; for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { @@ -14173,12 +14139,12 @@ test_xmlSAXParseDTD(void) { ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 1); SystemID = gen_const_xmlChar_ptr(n_SystemID, 2); - ret_val = xmlSAXParseDTD(sax, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + ret_val = xmlSAXParseDTD(sax, ExternalID, SystemID); desret_xmlDtdPtr(ret_val); call_tests++; des_xmlSAXHandlerPtr(n_sax, sax, 0); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 1); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 2); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 1); + des_const_xmlChar_ptr(n_SystemID, SystemID, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSAXParseDTD", @@ -14210,7 +14176,7 @@ test_xmlSAXParseDoc(void) { xmlDocPtr ret_val; xmlSAXHandlerPtr sax; /* the SAX handler block */ int n_sax; - xmlChar * cur; /* a pointer to an array of xmlChar */ + const xmlChar * cur; /* a pointer to an array of xmlChar */ int n_cur; int recovery; /* work in recovery mode, i.e. tries to read no Well Formed documents */ int n_recovery; @@ -14223,11 +14189,11 @@ test_xmlSAXParseDoc(void) { cur = gen_const_xmlChar_ptr(n_cur, 1); recovery = gen_int(n_recovery, 2); - ret_val = xmlSAXParseDoc(sax, (const xmlChar *)cur, recovery); + ret_val = xmlSAXParseDoc(sax, cur, recovery); desret_xmlDocPtr(ret_val); call_tests++; des_xmlSAXHandlerPtr(n_sax, sax, 0); - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_const_xmlChar_ptr(n_cur, cur, 1); des_int(n_recovery, recovery, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -14410,7 +14376,7 @@ test_xmlSAXParseMemory(void) { xmlDocPtr ret_val; xmlSAXHandlerPtr sax; /* the SAX handler block */ int n_sax; - char * buffer; /* an pointer to a char array */ + const char * buffer; /* an pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -14430,11 +14396,11 @@ test_xmlSAXParseMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlSAXParseMemory(sax, (const char *)buffer, size, recovery); + ret_val = xmlSAXParseMemory(sax, buffer, size, recovery); desret_xmlDocPtr(ret_val); call_tests++; des_xmlSAXHandlerPtr(n_sax, sax, 0); - des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_const_char_ptr(n_buffer, buffer, 1); des_int(n_size, size, 2); des_int(n_recovery, recovery, 3); xmlResetLastError(); @@ -14470,7 +14436,7 @@ test_xmlSAXParseMemoryWithData(void) { xmlDocPtr ret_val; xmlSAXHandlerPtr sax; /* the SAX handler block */ int n_sax; - char * buffer; /* an pointer to a char array */ + const char * buffer; /* an pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -14494,11 +14460,11 @@ test_xmlSAXParseMemoryWithData(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlSAXParseMemoryWithData(sax, (const char *)buffer, size, recovery, data); + ret_val = xmlSAXParseMemoryWithData(sax, buffer, size, recovery, data); desret_xmlDocPtr(ret_val); call_tests++; des_xmlSAXHandlerPtr(n_sax, sax, 0); - des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_const_char_ptr(n_buffer, buffer, 1); des_int(n_size, size, 2); des_int(n_recovery, recovery, 3); des_userdata(n_data, data, 4); @@ -14594,7 +14560,7 @@ test_xmlSAXUserParseMemory(void) { int n_sax; void * user_data; /* The user data returned on SAX callbacks */ int n_user_data; - char * buffer; /* an in-memory XML document input */ + const char * buffer; /* an in-memory XML document input */ int n_buffer; int size; /* the length of the XML document in bytes */ int n_size; @@ -14617,12 +14583,12 @@ test_xmlSAXUserParseMemory(void) { #endif - ret_val = xmlSAXUserParseMemory(sax, user_data, (const char *)buffer, size); + ret_val = xmlSAXUserParseMemory(sax, user_data, buffer, size); desret_int(ret_val); call_tests++; des_xmlSAXHandlerPtr(n_sax, sax, 0); des_userdata(n_user_data, user_data, 1); - des_const_char_ptr(n_buffer, (const char *)buffer, 2); + des_const_char_ptr(n_buffer, buffer, 2); des_int(n_size, size, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -14666,7 +14632,7 @@ test_xmlSetupParserForBuffer(void) { int mem_base; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - xmlChar * buffer; /* a xmlChar * buffer */ + const xmlChar * buffer; /* a xmlChar * buffer */ int n_buffer; const char * filename; /* a file name */ int n_filename; @@ -14679,10 +14645,10 @@ test_xmlSetupParserForBuffer(void) { buffer = gen_const_xmlChar_ptr(n_buffer, 1); filename = gen_filepath(n_filename, 2); - xmlSetupParserForBuffer(ctxt, (const xmlChar *)buffer, filename); + xmlSetupParserForBuffer(ctxt, buffer, filename); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_buffer, (const xmlChar *)buffer, 1); + des_const_xmlChar_ptr(n_buffer, buffer, 1); des_filepath(n_filename, filename, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -15216,7 +15182,7 @@ test_namePush(void) { int ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - xmlChar * value; /* the element name */ + const xmlChar * value; /* the element name */ int n_value; for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { @@ -15225,11 +15191,11 @@ test_namePush(void) { ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); value = gen_const_xmlChar_ptr(n_value, 1); - ret_val = namePush(ctxt, (const xmlChar *)value); + ret_val = namePush(ctxt, value); desret_int(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in namePush", @@ -15324,17 +15290,17 @@ test_xmlCheckLanguageID(void) { int mem_base; int ret_val; - xmlChar * lang; /* pointer to the string value */ + const xmlChar * lang; /* pointer to the string value */ int n_lang; for (n_lang = 0;n_lang < gen_nb_const_xmlChar_ptr;n_lang++) { mem_base = xmlMemBlocks(); lang = gen_const_xmlChar_ptr(n_lang, 0); - ret_val = xmlCheckLanguageID((const xmlChar *)lang); + ret_val = xmlCheckLanguageID(lang); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_lang, (const xmlChar *)lang, 0); + des_const_xmlChar_ptr(n_lang, lang, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCheckLanguageID", @@ -15441,11 +15407,11 @@ test_xmlCreateEntityParserCtxt(void) { int mem_base; xmlParserCtxtPtr ret_val; - xmlChar * URL; /* the entity URL */ + const xmlChar * URL; /* the entity URL */ int n_URL; - xmlChar * ID; /* the entity PUBLIC ID */ + const xmlChar * ID; /* the entity PUBLIC ID */ int n_ID; - xmlChar * base; /* a possible base for the target URI */ + const xmlChar * base; /* a possible base for the target URI */ int n_base; for (n_URL = 0;n_URL < gen_nb_const_xmlChar_ptr;n_URL++) { @@ -15456,12 +15422,12 @@ test_xmlCreateEntityParserCtxt(void) { ID = gen_const_xmlChar_ptr(n_ID, 1); base = gen_const_xmlChar_ptr(n_base, 2); - ret_val = xmlCreateEntityParserCtxt((const xmlChar *)URL, (const xmlChar *)ID, (const xmlChar *)base); + ret_val = xmlCreateEntityParserCtxt(URL, ID, base); desret_xmlParserCtxtPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_URL, (const xmlChar *)URL, 0); - des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 1); - des_const_xmlChar_ptr(n_base, (const xmlChar *)base, 2); + des_const_xmlChar_ptr(n_URL, URL, 0); + des_const_xmlChar_ptr(n_ID, ID, 1); + des_const_xmlChar_ptr(n_base, base, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCreateEntityParserCtxt", @@ -15519,7 +15485,7 @@ test_xmlCreateMemoryParserCtxt(void) { int mem_base; xmlParserCtxtPtr ret_val; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -15533,10 +15499,10 @@ test_xmlCreateMemoryParserCtxt(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlCreateMemoryParserCtxt((const char *)buffer, size); + ret_val = xmlCreateMemoryParserCtxt(buffer, size); desret_xmlParserCtxtPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -15783,7 +15749,7 @@ test_xmlNewStringInputStream(void) { xmlParserInputPtr ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - xmlChar * buffer; /* an memory buffer */ + const xmlChar * buffer; /* an memory buffer */ int n_buffer; for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { @@ -15792,11 +15758,11 @@ test_xmlNewStringInputStream(void) { ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); buffer = gen_const_xmlChar_ptr(n_buffer, 1); - ret_val = xmlNewStringInputStream(ctxt, (const xmlChar *)buffer); + ret_val = xmlNewStringInputStream(ctxt, buffer); desret_xmlParserInputPtr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_buffer, (const xmlChar *)buffer, 1); + des_const_xmlChar_ptr(n_buffer, buffer, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewStringInputStream", @@ -15963,7 +15929,7 @@ test_xmlSplitQName(void) { xmlChar * ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - xmlChar * name; /* an XML parser context */ + const xmlChar * name; /* an XML parser context */ int n_name; xmlChar ** prefix; /* a xmlChar ** */ int n_prefix; @@ -15976,11 +15942,11 @@ test_xmlSplitQName(void) { name = gen_const_xmlChar_ptr(n_name, 1); prefix = gen_xmlChar_ptr_ptr(n_prefix, 2); - ret_val = xmlSplitQName(ctxt, (const xmlChar *)name, prefix); + ret_val = xmlSplitQName(ctxt, name, prefix); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_xmlChar_ptr_ptr(n_prefix, prefix, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -16009,7 +15975,7 @@ test_xmlStringCurrentChar(void) { int ret_val; xmlParserCtxtPtr ctxt; /* the XML parser context */ int n_ctxt; - xmlChar * cur; /* pointer to the beginning of the char */ + const xmlChar * cur; /* pointer to the beginning of the char */ int n_cur; int * len; /* pointer to the length of the char read */ int n_len; @@ -16022,11 +15988,11 @@ test_xmlStringCurrentChar(void) { cur = gen_const_xmlChar_ptr(n_cur, 1); len = gen_int_ptr(n_len, 2); - ret_val = xmlStringCurrentChar(ctxt, (const xmlChar *)cur, len); + ret_val = xmlStringCurrentChar(ctxt, cur, len); desret_int(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_const_xmlChar_ptr(n_cur, cur, 1); des_int_ptr(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -16055,7 +16021,7 @@ test_xmlStringDecodeEntities(void) { xmlChar * ret_val; xmlParserCtxtPtr ctxt; /* the parser context */ int n_ctxt; - xmlChar * str; /* the input string */ + const xmlChar * str; /* the input string */ int n_str; int what; /* combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF */ int n_what; @@ -16080,11 +16046,11 @@ test_xmlStringDecodeEntities(void) { end2 = gen_xmlChar(n_end2, 4); end3 = gen_xmlChar(n_end3, 5); - ret_val = xmlStringDecodeEntities(ctxt, (const xmlChar *)str, what, end, end2, end3); + ret_val = xmlStringDecodeEntities(ctxt, str, what, end, end2, end3); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); des_int(n_what, what, 2); des_xmlChar(n_end, end, 3); des_xmlChar(n_end2, end2, 4); @@ -16122,7 +16088,7 @@ test_xmlStringLenDecodeEntities(void) { xmlChar * ret_val; xmlParserCtxtPtr ctxt; /* the parser context */ int n_ctxt; - xmlChar * str; /* the input string */ + const xmlChar * str; /* the input string */ int n_str; int len; /* the string length */ int n_len; @@ -16154,11 +16120,11 @@ test_xmlStringLenDecodeEntities(void) { (len > xmlStrlen(BAD_CAST str))) len = 0; - ret_val = xmlStringLenDecodeEntities(ctxt, (const xmlChar *)str, len, what, end, end2, end3); + ret_val = xmlStringLenDecodeEntities(ctxt, str, len, what, end, end2, end3); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); des_int(n_len, len, 2); des_int(n_what, what, 3); des_xmlChar(n_end, end, 4); @@ -16603,9 +16569,9 @@ test_xmlStreamPush(void) { int ret_val; xmlStreamCtxtPtr stream; /* the stream context */ int n_stream; - xmlChar * name; /* the current name */ + const xmlChar * name; /* the current name */ int n_name; - xmlChar * ns; /* the namespace name */ + const xmlChar * ns; /* the namespace name */ int n_ns; for (n_stream = 0;n_stream < gen_nb_xmlStreamCtxtPtr;n_stream++) { @@ -16616,12 +16582,12 @@ test_xmlStreamPush(void) { name = gen_const_xmlChar_ptr(n_name, 1); ns = gen_const_xmlChar_ptr(n_ns, 2); - ret_val = xmlStreamPush(stream, (const xmlChar *)name, (const xmlChar *)ns); + ret_val = xmlStreamPush(stream, name, ns); desret_int(ret_val); call_tests++; des_xmlStreamCtxtPtr(n_stream, stream, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ns, ns, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStreamPush", @@ -16651,9 +16617,9 @@ test_xmlStreamPushAttr(void) { int ret_val; xmlStreamCtxtPtr stream; /* the stream context */ int n_stream; - xmlChar * name; /* the current name */ + const xmlChar * name; /* the current name */ int n_name; - xmlChar * ns; /* the namespace name */ + const xmlChar * ns; /* the namespace name */ int n_ns; for (n_stream = 0;n_stream < gen_nb_xmlStreamCtxtPtr;n_stream++) { @@ -16664,12 +16630,12 @@ test_xmlStreamPushAttr(void) { name = gen_const_xmlChar_ptr(n_name, 1); ns = gen_const_xmlChar_ptr(n_ns, 2); - ret_val = xmlStreamPushAttr(stream, (const xmlChar *)name, (const xmlChar *)ns); + ret_val = xmlStreamPushAttr(stream, name, ns); desret_int(ret_val); call_tests++; des_xmlStreamCtxtPtr(n_stream, stream, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ns, ns, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStreamPushAttr", @@ -16699,9 +16665,9 @@ test_xmlStreamPushNode(void) { int ret_val; xmlStreamCtxtPtr stream; /* the stream context */ int n_stream; - xmlChar * name; /* the current name */ + const xmlChar * name; /* the current name */ int n_name; - xmlChar * ns; /* the namespace name */ + const xmlChar * ns; /* the namespace name */ int n_ns; int nodeType; /* the type of the node being pushed */ int n_nodeType; @@ -16716,12 +16682,12 @@ test_xmlStreamPushNode(void) { ns = gen_const_xmlChar_ptr(n_ns, 2); nodeType = gen_int(n_nodeType, 3); - ret_val = xmlStreamPushNode(stream, (const xmlChar *)name, (const xmlChar *)ns, nodeType); + ret_val = xmlStreamPushNode(stream, name, ns, nodeType); desret_int(ret_val); call_tests++; des_xmlStreamCtxtPtr(n_stream, stream, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ns, ns, 2); des_int(n_nodeType, nodeType, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -17092,7 +17058,7 @@ test_xmlRelaxNGNewMemParserCtxt(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; xmlRelaxNGParserCtxtPtr ret_val; - char * buffer; /* a pointer to a char array containing the schemas */ + const char * buffer; /* a pointer to a char array containing the schemas */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -17106,10 +17072,10 @@ test_xmlRelaxNGNewMemParserCtxt(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlRelaxNGNewMemParserCtxt((const char *)buffer, size); + ret_val = xmlRelaxNGNewMemParserCtxt(buffer, size); desret_xmlRelaxNGParserCtxtPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -17136,17 +17102,17 @@ test_xmlRelaxNGNewParserCtxt(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; xmlRelaxNGParserCtxtPtr ret_val; - char * URL; /* the location of the schema */ + const char * URL; /* the location of the schema */ int n_URL; for (n_URL = 0;n_URL < gen_nb_const_char_ptr;n_URL++) { mem_base = xmlMemBlocks(); URL = gen_const_char_ptr(n_URL, 0); - ret_val = xmlRelaxNGNewParserCtxt((const char *)URL); + ret_val = xmlRelaxNGNewParserCtxt(URL); desret_xmlRelaxNGParserCtxtPtr(ret_val); call_tests++; - des_const_char_ptr(n_URL, (const char *)URL, 0); + des_const_char_ptr(n_URL, URL, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlRelaxNGNewParserCtxt", @@ -17369,7 +17335,7 @@ test_xmlRelaxNGValidatePushCData(void) { int ret_val; xmlRelaxNGValidCtxtPtr ctxt; /* the RelaxNG validation context */ int n_ctxt; - xmlChar * data; /* some character data read */ + const xmlChar * data; /* some character data read */ int n_data; int len; /* the length of the data */ int n_len; @@ -17385,11 +17351,11 @@ test_xmlRelaxNGValidatePushCData(void) { (len > xmlStrlen(BAD_CAST data))) len = 0; - ret_val = xmlRelaxNGValidatePushCData(ctxt, (const xmlChar *)data, len); + ret_val = xmlRelaxNGValidatePushCData(ctxt, data, len); desret_int(ret_val); call_tests++; des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_data, (const xmlChar *)data, 1); + des_const_xmlChar_ptr(n_data, data, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -17880,7 +17846,7 @@ test_xmlAttrSerializeTxtContent(void) { int n_doc; xmlAttrPtr attr; /* the attribute node */ int n_attr; - xmlChar * string; /* the text content */ + const xmlChar * string; /* the text content */ int n_string; for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { @@ -17893,12 +17859,12 @@ test_xmlAttrSerializeTxtContent(void) { attr = gen_xmlAttrPtr(n_attr, 2); string = gen_const_xmlChar_ptr(n_string, 3); - xmlAttrSerializeTxtContent(buf, doc, attr, (const xmlChar *)string); + xmlAttrSerializeTxtContent(buf, doc, attr, string); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlAttrPtr(n_attr, attr, 2); - des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 3); + des_const_xmlChar_ptr(n_string, string, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlAttrSerializeTxtContent", @@ -17932,17 +17898,17 @@ test_xmlBufContent(void) { int mem_base; xmlChar * ret_val; - xmlBuf * buf; /* the buffer */ + const xmlBuf * buf; /* the buffer */ int n_buf; for (n_buf = 0;n_buf < gen_nb_const_xmlBuf_ptr;n_buf++) { mem_base = xmlMemBlocks(); buf = gen_const_xmlBuf_ptr(n_buf, 0); - ret_val = xmlBufContent((const xmlBuf *)buf); + ret_val = xmlBufContent(buf); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlBuf_ptr(n_buf, (const xmlBuf *)buf, 0); + des_const_xmlBuf_ptr(n_buf, buf, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufContent", @@ -18006,7 +17972,7 @@ test_xmlBufGetNodeContent(void) { int ret_val; xmlBufPtr buf; /* a buffer xmlBufPtr */ int n_buf; - xmlNode * cur; /* the node being read */ + const xmlNode * cur; /* the node being read */ int n_cur; for (n_buf = 0;n_buf < gen_nb_xmlBufPtr;n_buf++) { @@ -18015,11 +17981,11 @@ test_xmlBufGetNodeContent(void) { buf = gen_xmlBufPtr(n_buf, 0); cur = gen_const_xmlNode_ptr(n_cur, 1); - ret_val = xmlBufGetNodeContent(buf, (const xmlNode *)cur); + ret_val = xmlBufGetNodeContent(buf, cur); desret_int(ret_val); call_tests++; des_xmlBufPtr(n_buf, buf, 0); - des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 1); + des_const_xmlNode_ptr(n_cur, cur, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufGetNodeContent", @@ -18075,7 +18041,7 @@ test_xmlBufferAdd(void) { int ret_val; xmlBufferPtr buf; /* the buffer to dump */ int n_buf; - xmlChar * str; /* the #xmlChar string */ + const xmlChar * str; /* the #xmlChar string */ int n_str; int len; /* the number of #xmlChar to add */ int n_len; @@ -18091,11 +18057,11 @@ test_xmlBufferAdd(void) { (len > xmlStrlen(BAD_CAST str))) len = 0; - ret_val = xmlBufferAdd(buf, (const xmlChar *)str, len); + ret_val = xmlBufferAdd(buf, str, len); desret_int(ret_val); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -18124,7 +18090,7 @@ test_xmlBufferAddHead(void) { int ret_val; xmlBufferPtr buf; /* the buffer */ int n_buf; - xmlChar * str; /* the #xmlChar string */ + const xmlChar * str; /* the #xmlChar string */ int n_str; int len; /* the number of #xmlChar to add */ int n_len; @@ -18140,11 +18106,11 @@ test_xmlBufferAddHead(void) { (len > xmlStrlen(BAD_CAST str))) len = 0; - ret_val = xmlBufferAddHead(buf, (const xmlChar *)str, len); + ret_val = xmlBufferAddHead(buf, str, len); desret_int(ret_val); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -18173,7 +18139,7 @@ test_xmlBufferCCat(void) { int ret_val; xmlBufferPtr buf; /* the buffer to dump */ int n_buf; - char * str; /* the C char string */ + const char * str; /* the C char string */ int n_str; for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { @@ -18182,11 +18148,11 @@ test_xmlBufferCCat(void) { buf = gen_xmlBufferPtr(n_buf, 0); str = gen_const_char_ptr(n_str, 1); - ret_val = xmlBufferCCat(buf, (const char *)str); + ret_val = xmlBufferCCat(buf, str); desret_int(ret_val); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); - des_const_char_ptr(n_str, (const char *)str, 1); + des_const_char_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufferCCat", @@ -18212,7 +18178,7 @@ test_xmlBufferCat(void) { int ret_val; xmlBufferPtr buf; /* the buffer to add to */ int n_buf; - xmlChar * str; /* the #xmlChar string */ + const xmlChar * str; /* the #xmlChar string */ int n_str; for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { @@ -18221,11 +18187,11 @@ test_xmlBufferCat(void) { buf = gen_xmlBufferPtr(n_buf, 0); str = gen_const_xmlChar_ptr(n_str, 1); - ret_val = xmlBufferCat(buf, (const xmlChar *)str); + ret_val = xmlBufferCat(buf, str); desret_int(ret_val); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufferCat", @@ -18253,17 +18219,17 @@ test_xmlBufferContent(void) { int mem_base; const xmlChar * ret_val; - xmlBuffer * buf; /* the buffer */ + const xmlBuffer * buf; /* the buffer */ int n_buf; for (n_buf = 0;n_buf < gen_nb_const_xmlBuffer_ptr;n_buf++) { mem_base = xmlMemBlocks(); buf = gen_const_xmlBuffer_ptr(n_buf, 0); - ret_val = xmlBufferContent((const xmlBuffer *)buf); + ret_val = xmlBufferContent(buf); desret_const_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlBuffer_ptr(n_buf, (const xmlBuffer *)buf, 0); + des_const_xmlBuffer_ptr(n_buf, buf, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufferContent", @@ -18431,17 +18397,17 @@ test_xmlBufferLength(void) { int mem_base; int ret_val; - xmlBuffer * buf; /* the buffer */ + const xmlBuffer * buf; /* the buffer */ int n_buf; for (n_buf = 0;n_buf < gen_nb_const_xmlBuffer_ptr;n_buf++) { mem_base = xmlMemBlocks(); buf = gen_const_xmlBuffer_ptr(n_buf, 0); - ret_val = xmlBufferLength((const xmlBuffer *)buf); + ret_val = xmlBufferLength(buf); desret_int(ret_val); call_tests++; - des_const_xmlBuffer_ptr(n_buf, (const xmlBuffer *)buf, 0); + des_const_xmlBuffer_ptr(n_buf, buf, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufferLength", @@ -18579,7 +18545,7 @@ test_xmlBufferWriteCHAR(void) { int mem_base; xmlBufferPtr buf; /* the XML buffer */ int n_buf; - xmlChar * string; /* the string to add */ + const xmlChar * string; /* the string to add */ int n_string; for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { @@ -18588,10 +18554,10 @@ test_xmlBufferWriteCHAR(void) { buf = gen_xmlBufferPtr(n_buf, 0); string = gen_const_xmlChar_ptr(n_string, 1); - xmlBufferWriteCHAR(buf, (const xmlChar *)string); + xmlBufferWriteCHAR(buf, string); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); - des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 1); + des_const_xmlChar_ptr(n_string, string, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufferWriteCHAR", @@ -18616,7 +18582,7 @@ test_xmlBufferWriteChar(void) { int mem_base; xmlBufferPtr buf; /* the XML buffer output */ int n_buf; - char * string; /* the string to add */ + const char * string; /* the string to add */ int n_string; for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { @@ -18625,10 +18591,10 @@ test_xmlBufferWriteChar(void) { buf = gen_xmlBufferPtr(n_buf, 0); string = gen_const_char_ptr(n_string, 1); - xmlBufferWriteChar(buf, (const char *)string); + xmlBufferWriteChar(buf, string); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); - des_const_char_ptr(n_string, (const char *)string, 1); + des_const_char_ptr(n_string, string, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufferWriteChar", @@ -18653,7 +18619,7 @@ test_xmlBufferWriteQuotedString(void) { int mem_base; xmlBufferPtr buf; /* the XML buffer output */ int n_buf; - xmlChar * string; /* the string to add */ + const xmlChar * string; /* the string to add */ int n_string; for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) { @@ -18662,10 +18628,10 @@ test_xmlBufferWriteQuotedString(void) { buf = gen_xmlBufferPtr(n_buf, 0); string = gen_const_xmlChar_ptr(n_string, 1); - xmlBufferWriteQuotedString(buf, (const xmlChar *)string); + xmlBufferWriteQuotedString(buf, string); call_tests++; des_xmlBufferPtr(n_buf, buf, 0); - des_const_xmlChar_ptr(n_string, (const xmlChar *)string, 1); + des_const_xmlChar_ptr(n_string, string, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBufferWriteQuotedString", @@ -18689,9 +18655,9 @@ test_xmlBuildQName(void) { int mem_base; xmlChar * ret_val; - xmlChar * ncname; /* the Name */ + const xmlChar * ncname; /* the Name */ int n_ncname; - xmlChar * prefix; /* the prefix */ + const xmlChar * prefix; /* the prefix */ int n_prefix; xmlChar * memory; /* preallocated memory */ int n_memory; @@ -18711,15 +18677,15 @@ test_xmlBuildQName(void) { (len > xmlStrlen(BAD_CAST prefix))) len = 0; - ret_val = xmlBuildQName((const xmlChar *)ncname, (const xmlChar *)prefix, memory, len); + ret_val = xmlBuildQName(ncname, prefix, memory, len); if ((ret_val != NULL) && (ret_val != ncname) && (ret_val != prefix) && (ret_val != memory)) xmlFree(ret_val); ret_val = NULL; desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_ncname, (const xmlChar *)ncname, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_ncname, ncname, 0); + des_const_xmlChar_ptr(n_prefix, prefix, 1); des_xmlChar_ptr(n_memory, memory, 2); des_int(n_len, len, 3); xmlResetLastError(); @@ -19075,11 +19041,11 @@ test_xmlCreateIntSubset(void) { xmlDtdPtr ret_val; xmlDocPtr doc; /* the document pointer */ int n_doc; - xmlChar * name; /* the DTD name */ + const xmlChar * name; /* the DTD name */ int n_name; - xmlChar * ExternalID; /* the external (PUBLIC) ID */ + const xmlChar * ExternalID; /* the external (PUBLIC) ID */ int n_ExternalID; - xmlChar * SystemID; /* the system ID */ + const xmlChar * SystemID; /* the system ID */ int n_SystemID; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -19092,13 +19058,13 @@ test_xmlCreateIntSubset(void) { ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); - ret_val = xmlCreateIntSubset(doc, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + ret_val = xmlCreateIntSubset(doc, name, ExternalID, SystemID); desret_xmlDtdPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, SystemID, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCreateIntSubset", @@ -19583,7 +19549,7 @@ test_xmlDocDumpFormatMemoryEnc(void) { int n_doc_txt_ptr; int * doc_txt_len; /* Length of the generated XML text */ int n_doc_txt_len; - char * txt_encoding; /* Character encoding to use when generating XML text */ + const char * txt_encoding; /* Character encoding to use when generating XML text */ int n_txt_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -19600,12 +19566,12 @@ test_xmlDocDumpFormatMemoryEnc(void) { txt_encoding = gen_const_char_ptr(n_txt_encoding, 3); format = gen_int(n_format, 4); - xmlDocDumpFormatMemoryEnc(out_doc, doc_txt_ptr, doc_txt_len, (const char *)txt_encoding, format); + xmlDocDumpFormatMemoryEnc(out_doc, doc_txt_ptr, doc_txt_len, txt_encoding, format); call_tests++; des_xmlDocPtr(n_out_doc, out_doc, 0); des_xmlChar_ptr_ptr(n_doc_txt_ptr, doc_txt_ptr, 1); des_int_ptr(n_doc_txt_len, doc_txt_len, 2); - des_const_char_ptr(n_txt_encoding, (const char *)txt_encoding, 3); + des_const_char_ptr(n_txt_encoding, txt_encoding, 3); des_int(n_format, format, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -19689,7 +19655,7 @@ test_xmlDocDumpMemoryEnc(void) { int n_doc_txt_ptr; int * doc_txt_len; /* Length of the generated XML text */ int n_doc_txt_len; - char * txt_encoding; /* Character encoding to use when generating XML text */ + const char * txt_encoding; /* Character encoding to use when generating XML text */ int n_txt_encoding; for (n_out_doc = 0;n_out_doc < gen_nb_xmlDocPtr;n_out_doc++) { @@ -19702,12 +19668,12 @@ test_xmlDocDumpMemoryEnc(void) { doc_txt_len = gen_int_ptr(n_doc_txt_len, 2); txt_encoding = gen_const_char_ptr(n_txt_encoding, 3); - xmlDocDumpMemoryEnc(out_doc, doc_txt_ptr, doc_txt_len, (const char *)txt_encoding); + xmlDocDumpMemoryEnc(out_doc, doc_txt_ptr, doc_txt_len, txt_encoding); call_tests++; des_xmlDocPtr(n_out_doc, out_doc, 0); des_xmlChar_ptr_ptr(n_doc_txt_ptr, doc_txt_ptr, 1); des_int_ptr(n_doc_txt_len, doc_txt_len, 2); - des_const_char_ptr(n_txt_encoding, (const char *)txt_encoding, 3); + des_const_char_ptr(n_txt_encoding, txt_encoding, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlDocDumpMemoryEnc", @@ -19784,17 +19750,17 @@ test_xmlDocGetRootElement(void) { int mem_base; xmlNodePtr ret_val; - xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the document */ int n_doc; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { mem_base = xmlMemBlocks(); doc = gen_const_xmlDoc_ptr(n_doc, 0); - ret_val = xmlDocGetRootElement((const xmlDoc *)doc); + ret_val = xmlDocGetRootElement(doc); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlDoc_ptr(n_doc, doc, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlDocGetRootElement", @@ -19988,17 +19954,17 @@ test_xmlGetDocCompressMode(void) { int mem_base; int ret_val; - xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the document */ int n_doc; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { mem_base = xmlMemBlocks(); doc = gen_const_xmlDoc_ptr(n_doc, 0); - ret_val = xmlGetDocCompressMode((const xmlDoc *)doc); + ret_val = xmlGetDocCompressMode(doc); desret_int(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlDoc_ptr(n_doc, doc, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetDocCompressMode", @@ -20020,17 +19986,17 @@ test_xmlGetIntSubset(void) { int mem_base; xmlDtdPtr ret_val; - xmlDoc * doc; /* the document pointer */ + const xmlDoc * doc; /* the document pointer */ int n_doc; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { mem_base = xmlMemBlocks(); doc = gen_const_xmlDoc_ptr(n_doc, 0); - ret_val = xmlGetIntSubset((const xmlDoc *)doc); + ret_val = xmlGetIntSubset(doc); desret_xmlDtdPtr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); + des_const_xmlDoc_ptr(n_doc, doc, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetIntSubset", @@ -20052,17 +20018,17 @@ test_xmlGetLastChild(void) { int mem_base; xmlNodePtr ret_val; - xmlNode * parent; /* the parent node */ + const xmlNode * parent; /* the parent node */ int n_parent; for (n_parent = 0;n_parent < gen_nb_const_xmlNode_ptr;n_parent++) { mem_base = xmlMemBlocks(); parent = gen_const_xmlNode_ptr(n_parent, 0); - ret_val = xmlGetLastChild((const xmlNode *)parent); + ret_val = xmlGetLastChild(parent); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_parent, (const xmlNode *)parent, 0); + des_const_xmlNode_ptr(n_parent, parent, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetLastChild", @@ -20084,17 +20050,17 @@ test_xmlGetLineNo(void) { int mem_base; long ret_val; - xmlNode * node; /* valid node */ + const xmlNode * node; /* valid node */ int n_node; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { mem_base = xmlMemBlocks(); node = gen_const_xmlNode_ptr(n_node, 0); - ret_val = xmlGetLineNo((const xmlNode *)node); + ret_val = xmlGetLineNo(node); desret_long(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlNode_ptr(n_node, node, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetLineNo", @@ -20116,9 +20082,9 @@ test_xmlGetNoNsProp(void) { int mem_base; xmlChar * ret_val; - xmlNode * node; /* the node */ + const xmlNode * node; /* the node */ int n_node; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { @@ -20127,11 +20093,11 @@ test_xmlGetNoNsProp(void) { node = gen_const_xmlNode_ptr(n_node, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlGetNoNsProp((const xmlNode *)node, (const xmlChar *)name); + ret_val = xmlGetNoNsProp(node, name); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlNode_ptr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetNoNsProp", @@ -20156,17 +20122,17 @@ test_xmlGetNodePath(void) { #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) int mem_base; xmlChar * ret_val; - xmlNode * node; /* a node */ + const xmlNode * node; /* a node */ int n_node; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { mem_base = xmlMemBlocks(); node = gen_const_xmlNode_ptr(n_node, 0); - ret_val = xmlGetNodePath((const xmlNode *)node); + ret_val = xmlGetNodePath(node); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlNode_ptr(n_node, node, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetNodePath", @@ -20199,11 +20165,11 @@ test_xmlGetNsProp(void) { int mem_base; xmlChar * ret_val; - xmlNode * node; /* the node */ + const xmlNode * node; /* the node */ int n_node; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; - xmlChar * nameSpace; /* the URI of the namespace */ + const xmlChar * nameSpace; /* the URI of the namespace */ int n_nameSpace; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { @@ -20214,12 +20180,12 @@ test_xmlGetNsProp(void) { name = gen_const_xmlChar_ptr(n_name, 1); nameSpace = gen_const_xmlChar_ptr(n_nameSpace, 2); - ret_val = xmlGetNsProp((const xmlNode *)node, (const xmlChar *)name, (const xmlChar *)nameSpace); + ret_val = xmlGetNsProp(node, name, nameSpace); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_nameSpace, (const xmlChar *)nameSpace, 2); + des_const_xmlNode_ptr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_nameSpace, nameSpace, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetNsProp", @@ -20245,9 +20211,9 @@ test_xmlGetProp(void) { int mem_base; xmlChar * ret_val; - xmlNode * node; /* the node */ + const xmlNode * node; /* the node */ int n_node; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { @@ -20256,11 +20222,11 @@ test_xmlGetProp(void) { node = gen_const_xmlNode_ptr(n_node, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlGetProp((const xmlNode *)node, (const xmlChar *)name); + ret_val = xmlGetProp(node, name); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlNode_ptr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetProp", @@ -20284,11 +20250,11 @@ test_xmlHasNsProp(void) { int mem_base; xmlAttrPtr ret_val; - xmlNode * node; /* the node */ + const xmlNode * node; /* the node */ int n_node; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; - xmlChar * nameSpace; /* the URI of the namespace */ + const xmlChar * nameSpace; /* the URI of the namespace */ int n_nameSpace; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { @@ -20299,12 +20265,12 @@ test_xmlHasNsProp(void) { name = gen_const_xmlChar_ptr(n_name, 1); nameSpace = gen_const_xmlChar_ptr(n_nameSpace, 2); - ret_val = xmlHasNsProp((const xmlNode *)node, (const xmlChar *)name, (const xmlChar *)nameSpace); + ret_val = xmlHasNsProp(node, name, nameSpace); desret_xmlAttrPtr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_nameSpace, (const xmlChar *)nameSpace, 2); + des_const_xmlNode_ptr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_nameSpace, nameSpace, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHasNsProp", @@ -20330,9 +20296,9 @@ test_xmlHasProp(void) { int mem_base; xmlAttrPtr ret_val; - xmlNode * node; /* the node */ + const xmlNode * node; /* the node */ int n_node; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { @@ -20341,11 +20307,11 @@ test_xmlHasProp(void) { node = gen_const_xmlNode_ptr(n_node, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlHasProp((const xmlNode *)node, (const xmlChar *)name); + ret_val = xmlHasProp(node, name); desret_xmlAttrPtr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlNode_ptr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlHasProp", @@ -20369,17 +20335,17 @@ test_xmlIsBlankNode(void) { int mem_base; int ret_val; - xmlNode * node; /* the node */ + const xmlNode * node; /* the node */ int n_node; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { mem_base = xmlMemBlocks(); node = gen_const_xmlNode_ptr(n_node, 0); - ret_val = xmlIsBlankNode((const xmlNode *)node); + ret_val = xmlIsBlankNode(node); desret_int(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlNode_ptr(n_node, node, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlIsBlankNode", @@ -20401,9 +20367,9 @@ test_xmlIsXHTML(void) { int mem_base; int ret_val; - xmlChar * systemID; /* the system identifier */ + const xmlChar * systemID; /* the system identifier */ int n_systemID; - xmlChar * publicID; /* the public identifier */ + const xmlChar * publicID; /* the public identifier */ int n_publicID; for (n_systemID = 0;n_systemID < gen_nb_const_xmlChar_ptr;n_systemID++) { @@ -20412,11 +20378,11 @@ test_xmlIsXHTML(void) { systemID = gen_const_xmlChar_ptr(n_systemID, 0); publicID = gen_const_xmlChar_ptr(n_publicID, 1); - ret_val = xmlIsXHTML((const xmlChar *)systemID, (const xmlChar *)publicID); + ret_val = xmlIsXHTML(systemID, publicID); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_systemID, (const xmlChar *)systemID, 0); - des_const_xmlChar_ptr(n_publicID, (const xmlChar *)publicID, 1); + des_const_xmlChar_ptr(n_systemID, systemID, 0); + des_const_xmlChar_ptr(n_publicID, publicID, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlIsXHTML", @@ -20476,7 +20442,7 @@ test_xmlNewCDataBlock(void) { xmlNodePtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * content; /* the CDATA block content content */ + const xmlChar * content; /* the CDATA block content content */ int n_content; int len; /* the length of the block */ int n_len; @@ -20492,11 +20458,11 @@ test_xmlNewCDataBlock(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - ret_val = xmlNewCDataBlock(doc, (const xmlChar *)content, len); + ret_val = xmlNewCDataBlock(doc, content, len); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -20525,7 +20491,7 @@ test_xmlNewCharRef(void) { xmlNodePtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * name; /* the char ref string, starting with # or "&# ... ;" */ + const xmlChar * name; /* the char ref string, starting with # or "&# ... ;" */ int n_name; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20534,11 +20500,11 @@ test_xmlNewCharRef(void) { doc = gen_xmlDocPtr(n_doc, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlNewCharRef(doc, (const xmlChar *)name); + ret_val = xmlNewCharRef(doc, name); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewCharRef", @@ -20568,9 +20534,9 @@ test_xmlNewChild(void) { int n_parent; xmlNsPtr ns; /* a namespace if any */ int n_ns; - xmlChar * name; /* the name of the child */ + const xmlChar * name; /* the name of the child */ int n_name; - xmlChar * content; /* the XML content of the child if any. */ + const xmlChar * content; /* the XML content of the child if any. */ int n_content; for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { @@ -20583,13 +20549,13 @@ test_xmlNewChild(void) { name = gen_const_xmlChar_ptr(n_name, 2); content = gen_const_xmlChar_ptr(n_content, 3); - ret_val = xmlNewChild(parent, ns, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlNewChild(parent, ns, name, content); desret_xmlNodePtr(ret_val); call_tests++; des_xmlNodePtr(n_parent, parent, 0); des_xmlNsPtr(n_ns, ns, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_content, content, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewChild", @@ -20619,17 +20585,17 @@ test_xmlNewComment(void) { int mem_base; xmlNodePtr ret_val; - xmlChar * content; /* the comment content */ + const xmlChar * content; /* the comment content */ int n_content; for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { mem_base = xmlMemBlocks(); content = gen_const_xmlChar_ptr(n_content, 0); - ret_val = xmlNewComment((const xmlChar *)content); + ret_val = xmlNewComment(content); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 0); + des_const_xmlChar_ptr(n_content, content, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewComment", @@ -20651,17 +20617,17 @@ test_xmlNewDoc(void) { int mem_base; xmlDocPtr ret_val; - xmlChar * version; /* xmlChar string giving the version of XML "1.0" */ + const xmlChar * version; /* xmlChar string giving the version of XML "1.0" */ int n_version; for (n_version = 0;n_version < gen_nb_const_xmlChar_ptr;n_version++) { mem_base = xmlMemBlocks(); version = gen_const_xmlChar_ptr(n_version, 0); - ret_val = xmlNewDoc((const xmlChar *)version); + ret_val = xmlNewDoc(version); desret_xmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_version, (const xmlChar *)version, 0); + des_const_xmlChar_ptr(n_version, version, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDoc", @@ -20685,7 +20651,7 @@ test_xmlNewDocComment(void) { xmlNodePtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * content; /* the comment content */ + const xmlChar * content; /* the comment content */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20694,11 +20660,11 @@ test_xmlNewDocComment(void) { doc = gen_xmlDocPtr(n_doc, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlNewDocComment(doc, (const xmlChar *)content); + ret_val = xmlNewDocComment(doc, content); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDocComment", @@ -20760,9 +20726,9 @@ test_xmlNewDocNode(void) { int n_doc; xmlNsPtr ns; /* namespace if any */ int n_ns; - xmlChar * name; /* the node name */ + const xmlChar * name; /* the node name */ int n_name; - xmlChar * content; /* the XML text content if any */ + const xmlChar * content; /* the XML text content if any */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20775,13 +20741,13 @@ test_xmlNewDocNode(void) { name = gen_const_xmlChar_ptr(n_name, 2); content = gen_const_xmlChar_ptr(n_content, 3); - ret_val = xmlNewDocNode(doc, ns, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlNewDocNode(doc, ns, name, content); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNsPtr(n_ns, ns, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_content, content, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDocNode", @@ -20815,7 +20781,7 @@ test_xmlNewDocNodeEatName(void) { int n_ns; xmlChar * name; /* the node name */ int n_name; - xmlChar * content; /* the XML text content if any */ + const xmlChar * content; /* the XML text content if any */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20828,13 +20794,13 @@ test_xmlNewDocNodeEatName(void) { name = gen_eaten_name(n_name, 2); content = gen_const_xmlChar_ptr(n_content, 3); - ret_val = xmlNewDocNodeEatName(doc, ns, name, (const xmlChar *)content); + ret_val = xmlNewDocNodeEatName(doc, ns, name, content); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNsPtr(n_ns, ns, 1); des_eaten_name(n_name, name, 2); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + des_const_xmlChar_ptr(n_content, content, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDocNodeEatName", @@ -20864,9 +20830,9 @@ test_xmlNewDocPI(void) { xmlNodePtr ret_val; xmlDocPtr doc; /* the target document */ int n_doc; - xmlChar * name; /* the processing instruction name */ + const xmlChar * name; /* the processing instruction name */ int n_name; - xmlChar * content; /* the PI content */ + const xmlChar * content; /* the PI content */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20877,12 +20843,12 @@ test_xmlNewDocPI(void) { name = gen_const_xmlChar_ptr(n_name, 1); content = gen_const_xmlChar_ptr(n_content, 2); - ret_val = xmlNewDocPI(doc, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlNewDocPI(doc, name, content); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_content, content, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDocPI", @@ -20910,9 +20876,9 @@ test_xmlNewDocProp(void) { xmlAttrPtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * name; /* the name of the attribute */ + const xmlChar * name; /* the name of the attribute */ int n_name; - xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute */ int n_value; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20923,12 +20889,12 @@ test_xmlNewDocProp(void) { name = gen_const_xmlChar_ptr(n_name, 1); value = gen_const_xmlChar_ptr(n_value, 2); - ret_val = xmlNewDocProp(doc, (const xmlChar *)name, (const xmlChar *)value); + ret_val = xmlNewDocProp(doc, name, value); desret_xmlAttrPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_value, value, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDocProp", @@ -20960,9 +20926,9 @@ test_xmlNewDocRawNode(void) { int n_doc; xmlNsPtr ns; /* namespace if any */ int n_ns; - xmlChar * name; /* the node name */ + const xmlChar * name; /* the node name */ int n_name; - xmlChar * content; /* the text content if any */ + const xmlChar * content; /* the text content if any */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20975,13 +20941,13 @@ test_xmlNewDocRawNode(void) { name = gen_const_xmlChar_ptr(n_name, 2); content = gen_const_xmlChar_ptr(n_content, 3); - ret_val = xmlNewDocRawNode(doc, ns, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlNewDocRawNode(doc, ns, name, content); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNsPtr(n_ns, ns, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_content, content, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDocRawNode", @@ -21011,9 +20977,9 @@ test_xmlNewDocText(void) { int mem_base; xmlNodePtr ret_val; - xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the document */ int n_doc; - xmlChar * content; /* the text content */ + const xmlChar * content; /* the text content */ int n_content; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -21022,11 +20988,11 @@ test_xmlNewDocText(void) { doc = gen_const_xmlDoc_ptr(n_doc, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlNewDocText((const xmlDoc *)doc, (const xmlChar *)content); + ret_val = xmlNewDocText(doc, content); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDocText", @@ -21052,7 +21018,7 @@ test_xmlNewDocTextLen(void) { xmlNodePtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * content; /* the text content */ + const xmlChar * content; /* the text content */ int n_content; int len; /* the text len. */ int n_len; @@ -21068,11 +21034,11 @@ test_xmlNewDocTextLen(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - ret_val = xmlNewDocTextLen(doc, (const xmlChar *)content, len); + ret_val = xmlNewDocTextLen(doc, content, len); desret_xmlNodePtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -21101,11 +21067,11 @@ test_xmlNewDtd(void) { xmlDtdPtr ret_val; xmlDocPtr doc; /* the document pointer */ int n_doc; - xmlChar * name; /* the DTD name */ + const xmlChar * name; /* the DTD name */ int n_name; - xmlChar * ExternalID; /* the external ID */ + const xmlChar * ExternalID; /* the external ID */ int n_ExternalID; - xmlChar * SystemID; /* the system ID */ + const xmlChar * SystemID; /* the system ID */ int n_SystemID; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -21118,13 +21084,13 @@ test_xmlNewDtd(void) { ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 2); SystemID = gen_const_xmlChar_ptr(n_SystemID, 3); - ret_val = xmlNewDtd(doc, (const xmlChar *)name, (const xmlChar *)ExternalID, (const xmlChar *)SystemID); + ret_val = xmlNewDtd(doc, name, ExternalID, SystemID); desret_xmlDtdPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ExternalID, (const xmlChar *)ExternalID, 2); - des_const_xmlChar_ptr(n_SystemID, (const xmlChar *)SystemID, 3); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 2); + des_const_xmlChar_ptr(n_SystemID, SystemID, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewDtd", @@ -21154,7 +21120,7 @@ test_xmlNewNode(void) { xmlNodePtr ret_val; xmlNsPtr ns; /* namespace if any */ int n_ns; - xmlChar * name; /* the node name */ + const xmlChar * name; /* the node name */ int n_name; for (n_ns = 0;n_ns < gen_nb_xmlNsPtr;n_ns++) { @@ -21163,11 +21129,11 @@ test_xmlNewNode(void) { ns = gen_xmlNsPtr(n_ns, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlNewNode(ns, (const xmlChar *)name); + ret_val = xmlNewNode(ns, name); desret_xmlNodePtr(ret_val); call_tests++; des_xmlNsPtr(n_ns, ns, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewNode", @@ -21232,9 +21198,9 @@ test_xmlNewNs(void) { xmlNsPtr ret_val; xmlNodePtr node; /* the element carrying the namespace */ int n_node; - xmlChar * href; /* the URI associated */ + const xmlChar * href; /* the URI associated */ int n_href; - xmlChar * prefix; /* the prefix for the namespace */ + const xmlChar * prefix; /* the prefix for the namespace */ int n_prefix; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21245,13 +21211,13 @@ test_xmlNewNs(void) { href = gen_const_xmlChar_ptr(n_href, 1); prefix = gen_const_xmlChar_ptr(n_prefix, 2); - ret_val = xmlNewNs(node, (const xmlChar *)href, (const xmlChar *)prefix); + ret_val = xmlNewNs(node, href, prefix); if ((node == NULL) && (ret_val != NULL)) xmlFreeNs(ret_val); desret_xmlNsPtr(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); - des_const_xmlChar_ptr(n_href, (const xmlChar *)href, 1); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); + des_const_xmlChar_ptr(n_href, href, 1); + des_const_xmlChar_ptr(n_prefix, prefix, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewNs", @@ -21281,9 +21247,9 @@ test_xmlNewNsProp(void) { int n_node; xmlNsPtr ns; /* the namespace */ int n_ns; - xmlChar * name; /* the name of the attribute */ + const xmlChar * name; /* the name of the attribute */ int n_name; - xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21296,13 +21262,13 @@ test_xmlNewNsProp(void) { name = gen_const_xmlChar_ptr(n_name, 2); value = gen_const_xmlChar_ptr(n_value, 3); - ret_val = xmlNewNsProp(node, ns, (const xmlChar *)name, (const xmlChar *)value); + ret_val = xmlNewNsProp(node, ns, name, value); desret_xmlAttrPtr(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); des_xmlNsPtr(n_ns, ns, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_value, value, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewNsProp", @@ -21336,7 +21302,7 @@ test_xmlNewNsPropEatName(void) { int n_ns; xmlChar * name; /* the name of the attribute */ int n_name; - xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21349,13 +21315,13 @@ test_xmlNewNsPropEatName(void) { name = gen_eaten_name(n_name, 2); value = gen_const_xmlChar_ptr(n_value, 3); - ret_val = xmlNewNsPropEatName(node, ns, name, (const xmlChar *)value); + ret_val = xmlNewNsPropEatName(node, ns, name, value); desret_xmlAttrPtr(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); des_xmlNsPtr(n_ns, ns, 1); des_eaten_name(n_name, name, 2); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + des_const_xmlChar_ptr(n_value, value, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewNsPropEatName", @@ -21383,9 +21349,9 @@ test_xmlNewPI(void) { int mem_base; xmlNodePtr ret_val; - xmlChar * name; /* the processing instruction name */ + const xmlChar * name; /* the processing instruction name */ int n_name; - xmlChar * content; /* the PI content */ + const xmlChar * content; /* the PI content */ int n_content; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { @@ -21394,11 +21360,11 @@ test_xmlNewPI(void) { name = gen_const_xmlChar_ptr(n_name, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlNewPI((const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlNewPI(name, content); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_name, name, 0); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewPI", @@ -21426,9 +21392,9 @@ test_xmlNewProp(void) { xmlAttrPtr ret_val; xmlNodePtr node; /* the holding node */ int n_node; - xmlChar * name; /* the name of the attribute */ + const xmlChar * name; /* the name of the attribute */ int n_name; - xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21439,12 +21405,12 @@ test_xmlNewProp(void) { name = gen_const_xmlChar_ptr(n_name, 1); value = gen_const_xmlChar_ptr(n_value, 2); - ret_val = xmlNewProp(node, (const xmlChar *)name, (const xmlChar *)value); + ret_val = xmlNewProp(node, name, value); desret_xmlAttrPtr(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_value, value, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewProp", @@ -21472,9 +21438,9 @@ test_xmlNewReference(void) { int mem_base; xmlNodePtr ret_val; - xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the document */ int n_doc; - xmlChar * name; /* the reference name, or the reference string with & and ; */ + const xmlChar * name; /* the reference name, or the reference string with & and ; */ int n_name; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -21483,11 +21449,11 @@ test_xmlNewReference(void) { doc = gen_const_xmlDoc_ptr(n_doc, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlNewReference((const xmlDoc *)doc, (const xmlChar *)name); + ret_val = xmlNewReference(doc, name); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewReference", @@ -21511,17 +21477,17 @@ test_xmlNewText(void) { int mem_base; xmlNodePtr ret_val; - xmlChar * content; /* the text content */ + const xmlChar * content; /* the text content */ int n_content; for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { mem_base = xmlMemBlocks(); content = gen_const_xmlChar_ptr(n_content, 0); - ret_val = xmlNewText((const xmlChar *)content); + ret_val = xmlNewText(content); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 0); + des_const_xmlChar_ptr(n_content, content, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewText", @@ -21549,9 +21515,9 @@ test_xmlNewTextChild(void) { int n_parent; xmlNsPtr ns; /* a namespace if any */ int n_ns; - xmlChar * name; /* the name of the child */ + const xmlChar * name; /* the name of the child */ int n_name; - xmlChar * content; /* the text content of the child if any. */ + const xmlChar * content; /* the text content of the child if any. */ int n_content; for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { @@ -21564,13 +21530,13 @@ test_xmlNewTextChild(void) { name = gen_const_xmlChar_ptr(n_name, 2); content = gen_const_xmlChar_ptr(n_content, 3); - ret_val = xmlNewTextChild(parent, ns, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlNewTextChild(parent, ns, name, content); desret_xmlNodePtr(ret_val); call_tests++; des_xmlNodePtr(n_parent, parent, 0); des_xmlNsPtr(n_ns, ns, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_content, content, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewTextChild", @@ -21600,7 +21566,7 @@ test_xmlNewTextLen(void) { int mem_base; xmlNodePtr ret_val; - xmlChar * content; /* the text content */ + const xmlChar * content; /* the text content */ int n_content; int len; /* the text len. */ int n_len; @@ -21614,10 +21580,10 @@ test_xmlNewTextLen(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - ret_val = xmlNewTextLen((const xmlChar *)content, len); + ret_val = xmlNewTextLen(content, len); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 0); + des_const_xmlChar_ptr(n_content, content, 0); des_int(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -21677,7 +21643,7 @@ test_xmlNodeAddContent(void) { int mem_base; xmlNodePtr cur; /* the node being modified */ int n_cur; - xmlChar * content; /* extra content */ + const xmlChar * content; /* extra content */ int n_content; for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { @@ -21686,10 +21652,10 @@ test_xmlNodeAddContent(void) { cur = gen_xmlNodePtr(n_cur, 0); content = gen_const_xmlChar_ptr(n_content, 1); - xmlNodeAddContent(cur, (const xmlChar *)content); + xmlNodeAddContent(cur, content); call_tests++; des_xmlNodePtr(n_cur, cur, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeAddContent", @@ -21714,7 +21680,7 @@ test_xmlNodeAddContentLen(void) { int mem_base; xmlNodePtr cur; /* the node being modified */ int n_cur; - xmlChar * content; /* extra content */ + const xmlChar * content; /* extra content */ int n_content; int len; /* the size of @content */ int n_len; @@ -21730,10 +21696,10 @@ test_xmlNodeAddContentLen(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - xmlNodeAddContentLen(cur, (const xmlChar *)content, len); + xmlNodeAddContentLen(cur, content, len); call_tests++; des_xmlNodePtr(n_cur, cur, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -21762,7 +21728,7 @@ test_xmlNodeBufGetContent(void) { int ret_val; xmlBufferPtr buffer; /* a buffer */ int n_buffer; - xmlNode * cur; /* the node being read */ + const xmlNode * cur; /* the node being read */ int n_cur; for (n_buffer = 0;n_buffer < gen_nb_xmlBufferPtr;n_buffer++) { @@ -21771,11 +21737,11 @@ test_xmlNodeBufGetContent(void) { buffer = gen_xmlBufferPtr(n_buffer, 0); cur = gen_const_xmlNode_ptr(n_cur, 1); - ret_val = xmlNodeBufGetContent(buffer, (const xmlNode *)cur); + ret_val = xmlNodeBufGetContent(buffer, cur); desret_int(ret_val); call_tests++; des_xmlBufferPtr(n_buffer, buffer, 0); - des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 1); + des_const_xmlNode_ptr(n_cur, cur, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeBufGetContent", @@ -21871,7 +21837,7 @@ test_xmlNodeDumpOutput(void) { int n_level; int format; /* is formatting allowed */ int n_format; - char * encoding; /* an optional encoding string */ + const char * encoding; /* an optional encoding string */ int n_encoding; for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { @@ -21888,14 +21854,14 @@ test_xmlNodeDumpOutput(void) { format = gen_int(n_format, 4); encoding = gen_const_char_ptr(n_encoding, 5); - xmlNodeDumpOutput(buf, doc, cur, level, format, (const char *)encoding); + xmlNodeDumpOutput(buf, doc, cur, level, format, encoding); call_tests++; des_xmlOutputBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_cur, cur, 2); des_int(n_level, level, 3); des_int(n_format, format, 4); - des_const_char_ptr(n_encoding, (const char *)encoding, 5); + des_const_char_ptr(n_encoding, encoding, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeDumpOutput", @@ -21928,9 +21894,9 @@ test_xmlNodeGetBase(void) { int mem_base; xmlChar * ret_val; - xmlDoc * doc; /* the document the node pertains to */ + const xmlDoc * doc; /* the document the node pertains to */ int n_doc; - xmlNode * cur; /* the node being checked */ + const xmlNode * cur; /* the node being checked */ int n_cur; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -21939,11 +21905,11 @@ test_xmlNodeGetBase(void) { doc = gen_const_xmlDoc_ptr(n_doc, 0); cur = gen_const_xmlNode_ptr(n_cur, 1); - ret_val = xmlNodeGetBase((const xmlDoc *)doc, (const xmlNode *)cur); + ret_val = xmlNodeGetBase(doc, cur); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlNode_ptr(n_cur, cur, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeGetBase", @@ -21967,17 +21933,17 @@ test_xmlNodeGetContent(void) { int mem_base; xmlChar * ret_val; - xmlNode * cur; /* the node being read */ + const xmlNode * cur; /* the node being read */ int n_cur; for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { mem_base = xmlMemBlocks(); cur = gen_const_xmlNode_ptr(n_cur, 0); - ret_val = xmlNodeGetContent((const xmlNode *)cur); + ret_val = xmlNodeGetContent(cur); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 0); + des_const_xmlNode_ptr(n_cur, cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeGetContent", @@ -21999,17 +21965,17 @@ test_xmlNodeGetLang(void) { int mem_base; xmlChar * ret_val; - xmlNode * cur; /* the node being checked */ + const xmlNode * cur; /* the node being checked */ int n_cur; for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { mem_base = xmlMemBlocks(); cur = gen_const_xmlNode_ptr(n_cur, 0); - ret_val = xmlNodeGetLang((const xmlNode *)cur); + ret_val = xmlNodeGetLang(cur); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 0); + des_const_xmlNode_ptr(n_cur, cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeGetLang", @@ -22031,17 +21997,17 @@ test_xmlNodeGetSpacePreserve(void) { int mem_base; int ret_val; - xmlNode * cur; /* the node being checked */ + const xmlNode * cur; /* the node being checked */ int n_cur; for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { mem_base = xmlMemBlocks(); cur = gen_const_xmlNode_ptr(n_cur, 0); - ret_val = xmlNodeGetSpacePreserve((const xmlNode *)cur); + ret_val = xmlNodeGetSpacePreserve(cur); desret_int(ret_val); call_tests++; - des_const_xmlNode_ptr(n_cur, (const xmlNode *)cur, 0); + des_const_xmlNode_ptr(n_cur, cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeGetSpacePreserve", @@ -22063,17 +22029,17 @@ test_xmlNodeIsText(void) { int mem_base; int ret_val; - xmlNode * node; /* the node */ + const xmlNode * node; /* the node */ int n_node; for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { mem_base = xmlMemBlocks(); node = gen_const_xmlNode_ptr(n_node, 0); - ret_val = xmlNodeIsText((const xmlNode *)node); + ret_val = xmlNodeIsText(node); desret_int(ret_val); call_tests++; - des_const_xmlNode_ptr(n_node, (const xmlNode *)node, 0); + des_const_xmlNode_ptr(n_node, node, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeIsText", @@ -22096,9 +22062,9 @@ test_xmlNodeListGetRawString(void) { #if defined(LIBXML_TREE_ENABLED) int mem_base; xmlChar * ret_val; - xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the document */ int n_doc; - xmlNode * list; /* a Node list */ + const xmlNode * list; /* a Node list */ int n_list; int inLine; /* should we replace entity contents or show their external form */ int n_inLine; @@ -22111,11 +22077,11 @@ test_xmlNodeListGetRawString(void) { list = gen_const_xmlNode_ptr(n_list, 1); inLine = gen_int(n_inLine, 2); - ret_val = xmlNodeListGetRawString((const xmlDoc *)doc, (const xmlNode *)list, inLine); + ret_val = xmlNodeListGetRawString(doc, list, inLine); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlNode_ptr(n_list, (const xmlNode *)list, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlNode_ptr(n_list, list, 1); des_int(n_inLine, inLine, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -22145,7 +22111,7 @@ test_xmlNodeListGetString(void) { xmlChar * ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlNode * list; /* a Node list */ + const xmlNode * list; /* a Node list */ int n_list; int inLine; /* should we replace entity contents or show their external form */ int n_inLine; @@ -22158,11 +22124,11 @@ test_xmlNodeListGetString(void) { list = gen_const_xmlNode_ptr(n_list, 1); inLine = gen_int(n_inLine, 2); - ret_val = xmlNodeListGetString(doc, (const xmlNode *)list, inLine); + ret_val = xmlNodeListGetString(doc, list, inLine); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlNode_ptr(n_list, (const xmlNode *)list, 1); + des_const_xmlNode_ptr(n_list, list, 1); des_int(n_inLine, inLine, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -22191,7 +22157,7 @@ test_xmlNodeSetBase(void) { int mem_base; xmlNodePtr cur; /* the node being changed */ int n_cur; - xmlChar * uri; /* the new base URI */ + const xmlChar * uri; /* the new base URI */ int n_uri; for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { @@ -22200,10 +22166,10 @@ test_xmlNodeSetBase(void) { cur = gen_xmlNodePtr(n_cur, 0); uri = gen_const_xmlChar_ptr(n_uri, 1); - xmlNodeSetBase(cur, (const xmlChar *)uri); + xmlNodeSetBase(cur, uri); call_tests++; des_xmlNodePtr(n_cur, cur, 0); - des_const_xmlChar_ptr(n_uri, (const xmlChar *)uri, 1); + des_const_xmlChar_ptr(n_uri, uri, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeSetBase", @@ -22229,7 +22195,7 @@ test_xmlNodeSetContent(void) { int mem_base; xmlNodePtr cur; /* the node being modified */ int n_cur; - xmlChar * content; /* the new value of the content */ + const xmlChar * content; /* the new value of the content */ int n_content; for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { @@ -22238,10 +22204,10 @@ test_xmlNodeSetContent(void) { cur = gen_xmlNodePtr(n_cur, 0); content = gen_const_xmlChar_ptr(n_content, 1); - xmlNodeSetContent(cur, (const xmlChar *)content); + xmlNodeSetContent(cur, content); call_tests++; des_xmlNodePtr(n_cur, cur, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeSetContent", @@ -22267,7 +22233,7 @@ test_xmlNodeSetContentLen(void) { int mem_base; xmlNodePtr cur; /* the node being modified */ int n_cur; - xmlChar * content; /* the new value of the content */ + const xmlChar * content; /* the new value of the content */ int n_content; int len; /* the size of @content */ int n_len; @@ -22283,10 +22249,10 @@ test_xmlNodeSetContentLen(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - xmlNodeSetContentLen(cur, (const xmlChar *)content, len); + xmlNodeSetContentLen(cur, content, len); call_tests++; des_xmlNodePtr(n_cur, cur, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -22316,7 +22282,7 @@ test_xmlNodeSetLang(void) { int mem_base; xmlNodePtr cur; /* the node being changed */ int n_cur; - xmlChar * lang; /* the language description */ + const xmlChar * lang; /* the language description */ int n_lang; for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { @@ -22325,10 +22291,10 @@ test_xmlNodeSetLang(void) { cur = gen_xmlNodePtr(n_cur, 0); lang = gen_const_xmlChar_ptr(n_lang, 1); - xmlNodeSetLang(cur, (const xmlChar *)lang); + xmlNodeSetLang(cur, lang); call_tests++; des_xmlNodePtr(n_cur, cur, 0); - des_const_xmlChar_ptr(n_lang, (const xmlChar *)lang, 1); + des_const_xmlChar_ptr(n_lang, lang, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeSetLang", @@ -22355,7 +22321,7 @@ test_xmlNodeSetName(void) { int mem_base; xmlNodePtr cur; /* the node being changed */ int n_cur; - xmlChar * name; /* the new tag name */ + const xmlChar * name; /* the new tag name */ int n_name; for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { @@ -22364,10 +22330,10 @@ test_xmlNodeSetName(void) { cur = gen_xmlNodePtr(n_cur, 0); name = gen_const_xmlChar_ptr(n_name, 1); - xmlNodeSetName(cur, (const xmlChar *)name); + xmlNodeSetName(cur, name); call_tests++; des_xmlNodePtr(n_cur, cur, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNodeSetName", @@ -22645,7 +22611,7 @@ test_xmlSaveFileEnc(void) { int n_filename; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the name of an encoding (or NULL) */ + const char * encoding; /* the name of an encoding (or NULL) */ int n_encoding; for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { @@ -22656,12 +22622,12 @@ test_xmlSaveFileEnc(void) { cur = gen_xmlDocPtr(n_cur, 1); encoding = gen_const_char_ptr(n_encoding, 2); - ret_val = xmlSaveFileEnc(filename, cur, (const char *)encoding); + ret_val = xmlSaveFileEnc(filename, cur, encoding); desret_int(ret_val); call_tests++; des_fileoutput(n_filename, filename, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSaveFileEnc", @@ -22693,7 +22659,7 @@ test_xmlSaveFileTo(void) { int n_buf; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the encoding if any assuming the I/O layer handles the transcoding */ + const char * encoding; /* the encoding if any assuming the I/O layer handles the transcoding */ int n_encoding; for (n_buf = 0;n_buf < gen_nb_xmlOutputBufferPtr;n_buf++) { @@ -22704,13 +22670,13 @@ test_xmlSaveFileTo(void) { cur = gen_xmlDocPtr(n_cur, 1); encoding = gen_const_char_ptr(n_encoding, 2); - ret_val = xmlSaveFileTo(buf, cur, (const char *)encoding); + ret_val = xmlSaveFileTo(buf, cur, encoding); buf = NULL; desret_int(ret_val); call_tests++; des_xmlOutputBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSaveFileTo", @@ -22790,7 +22756,7 @@ test_xmlSaveFormatFileEnc(void) { int n_filename; xmlDocPtr cur; /* the document being saved */ int n_cur; - char * encoding; /* the name of the encoding to use or NULL. */ + const char * encoding; /* the name of the encoding to use or NULL. */ int n_encoding; int format; /* should formatting spaces be added. */ int n_format; @@ -22805,12 +22771,12 @@ test_xmlSaveFormatFileEnc(void) { encoding = gen_const_char_ptr(n_encoding, 2); format = gen_int(n_format, 3); - ret_val = xmlSaveFormatFileEnc(filename, cur, (const char *)encoding, format); + ret_val = xmlSaveFormatFileEnc(filename, cur, encoding, format); desret_int(ret_val); call_tests++; des_fileoutput(n_filename, filename, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_int(n_format, format, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -22845,7 +22811,7 @@ test_xmlSaveFormatFileTo(void) { int n_buf; xmlDocPtr cur; /* the document */ int n_cur; - char * encoding; /* the encoding if any assuming the I/O layer handles the transcoding */ + const char * encoding; /* the encoding if any assuming the I/O layer handles the transcoding */ int n_encoding; int format; /* should formatting spaces been added */ int n_format; @@ -22860,13 +22826,13 @@ test_xmlSaveFormatFileTo(void) { encoding = gen_const_char_ptr(n_encoding, 2); format = gen_int(n_format, 3); - ret_val = xmlSaveFormatFileTo(buf, cur, (const char *)encoding, format); + ret_val = xmlSaveFormatFileTo(buf, cur, encoding, format); buf = NULL; desret_int(ret_val); call_tests++; des_xmlOutputBufferPtr(n_buf, buf, 0); des_xmlDocPtr(n_cur, cur, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_int(n_format, format, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -22900,7 +22866,7 @@ test_xmlSearchNs(void) { int n_doc; xmlNodePtr node; /* the current node */ int n_node; - xmlChar * nameSpace; /* the namespace prefix */ + const xmlChar * nameSpace; /* the namespace prefix */ int n_nameSpace; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -22911,12 +22877,12 @@ test_xmlSearchNs(void) { node = gen_xmlNodePtr(n_node, 1); nameSpace = gen_const_xmlChar_ptr(n_nameSpace, 2); - ret_val = xmlSearchNs(doc, node, (const xmlChar *)nameSpace); + ret_val = xmlSearchNs(doc, node, nameSpace); desret_xmlNsPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNodePtr(n_node, node, 1); - des_const_xmlChar_ptr(n_nameSpace, (const xmlChar *)nameSpace, 2); + des_const_xmlChar_ptr(n_nameSpace, nameSpace, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSearchNs", @@ -22946,7 +22912,7 @@ test_xmlSearchNsByHref(void) { int n_doc; xmlNodePtr node; /* the current node */ int n_node; - xmlChar * href; /* the namespace value */ + const xmlChar * href; /* the namespace value */ int n_href; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -22957,12 +22923,12 @@ test_xmlSearchNsByHref(void) { node = gen_xmlNodePtr(n_node, 1); href = gen_const_xmlChar_ptr(n_href, 2); - ret_val = xmlSearchNsByHref(doc, node, (const xmlChar *)href); + ret_val = xmlSearchNsByHref(doc, node, href); desret_xmlNsPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNodePtr(n_node, node, 1); - des_const_xmlChar_ptr(n_href, (const xmlChar *)href, 2); + des_const_xmlChar_ptr(n_href, href, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSearchNsByHref", @@ -23127,9 +23093,9 @@ test_xmlSetNsProp(void) { int n_node; xmlNsPtr ns; /* the namespace definition */ int n_ns; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; - xmlChar * value; /* the attribute value */ + const xmlChar * value; /* the attribute value */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -23142,13 +23108,13 @@ test_xmlSetNsProp(void) { name = gen_const_xmlChar_ptr(n_name, 2); value = gen_const_xmlChar_ptr(n_value, 3); - ret_val = xmlSetNsProp(node, ns, (const xmlChar *)name, (const xmlChar *)value); + ret_val = xmlSetNsProp(node, ns, name, value); desret_xmlAttrPtr(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); des_xmlNsPtr(n_ns, ns, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_value, value, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSetNsProp", @@ -23180,9 +23146,9 @@ test_xmlSetProp(void) { xmlAttrPtr ret_val; xmlNodePtr node; /* the node */ int n_node; - xmlChar * name; /* the attribute name (a QName) */ + const xmlChar * name; /* the attribute name (a QName) */ int n_name; - xmlChar * value; /* the attribute value */ + const xmlChar * value; /* the attribute value */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -23193,12 +23159,12 @@ test_xmlSetProp(void) { name = gen_const_xmlChar_ptr(n_name, 1); value = gen_const_xmlChar_ptr(n_value, 2); - ret_val = xmlSetProp(node, (const xmlChar *)name, (const xmlChar *)value); + ret_val = xmlSetProp(node, name, value); desret_xmlAttrPtr(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_value, value, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSetProp", @@ -23225,7 +23191,7 @@ test_xmlSplitQName2(void) { int mem_base; xmlChar * ret_val; - xmlChar * name; /* the full QName */ + const xmlChar * name; /* the full QName */ int n_name; xmlChar ** prefix; /* a xmlChar ** */ int n_prefix; @@ -23236,10 +23202,10 @@ test_xmlSplitQName2(void) { name = gen_const_xmlChar_ptr(n_name, 0); prefix = gen_xmlChar_ptr_ptr(n_prefix, 1); - ret_val = xmlSplitQName2((const xmlChar *)name, prefix); + ret_val = xmlSplitQName2(name, prefix); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); des_xmlChar_ptr_ptr(n_prefix, prefix, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23264,7 +23230,7 @@ test_xmlSplitQName3(void) { int mem_base; const xmlChar * ret_val; - xmlChar * name; /* the full QName */ + const xmlChar * name; /* the full QName */ int n_name; int * len; /* an int * */ int n_len; @@ -23275,10 +23241,10 @@ test_xmlSplitQName3(void) { name = gen_const_xmlChar_ptr(n_name, 0); len = gen_int_ptr(n_len, 1); - ret_val = xmlSplitQName3((const xmlChar *)name, len); + ret_val = xmlSplitQName3(name, len); desret_const_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); des_int_ptr(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23303,9 +23269,9 @@ test_xmlStringGetNodeList(void) { int mem_base; xmlNodePtr ret_val; - xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the document */ int n_doc; - xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute */ int n_value; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -23314,11 +23280,11 @@ test_xmlStringGetNodeList(void) { doc = gen_const_xmlDoc_ptr(n_doc, 0); value = gen_const_xmlChar_ptr(n_value, 1); - ret_val = xmlStringGetNodeList((const xmlDoc *)doc, (const xmlChar *)value); + ret_val = xmlStringGetNodeList(doc, value); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_value, value, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStringGetNodeList", @@ -23342,9 +23308,9 @@ test_xmlStringLenGetNodeList(void) { int mem_base; xmlNodePtr ret_val; - xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the document */ int n_doc; - xmlChar * value; /* the value of the text */ + const xmlChar * value; /* the value of the text */ int n_value; int len; /* the length of the string value */ int n_len; @@ -23360,11 +23326,11 @@ test_xmlStringLenGetNodeList(void) { (len > xmlStrlen(BAD_CAST value))) len = 0; - ret_val = xmlStringLenGetNodeList((const xmlDoc *)doc, (const xmlChar *)value, len); + ret_val = xmlStringLenGetNodeList(doc, value, len); desret_xmlNodePtr(ret_val); call_tests++; - des_const_xmlDoc_ptr(n_doc, (const xmlDoc *)doc, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlChar_ptr(n_value, value, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23393,7 +23359,7 @@ test_xmlTextConcat(void) { int ret_val; xmlNodePtr node; /* the node */ int n_node; - xmlChar * content; /* the content */ + const xmlChar * content; /* the content */ int n_content; int len; /* @content length */ int n_len; @@ -23409,11 +23375,11 @@ test_xmlTextConcat(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - ret_val = xmlTextConcat(node, (const xmlChar *)content, len); + ret_val = xmlTextConcat(node, content, len); desret_int(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23571,7 +23537,7 @@ test_xmlUnsetNsProp(void) { int n_node; xmlNsPtr ns; /* the namespace definition */ int n_ns; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -23582,12 +23548,12 @@ test_xmlUnsetNsProp(void) { ns = gen_xmlNsPtr(n_ns, 1); name = gen_const_xmlChar_ptr(n_name, 2); - ret_val = xmlUnsetNsProp(node, ns, (const xmlChar *)name); + ret_val = xmlUnsetNsProp(node, ns, name); desret_int(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); des_xmlNsPtr(n_ns, ns, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_name, name, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUnsetNsProp", @@ -23617,7 +23583,7 @@ test_xmlUnsetProp(void) { int ret_val; xmlNodePtr node; /* the node */ int n_node; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -23626,11 +23592,11 @@ test_xmlUnsetProp(void) { node = gen_xmlNodePtr(n_node, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlUnsetProp(node, (const xmlChar *)name); + ret_val = xmlUnsetProp(node, name); desret_int(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUnsetProp", @@ -23656,7 +23622,7 @@ test_xmlValidateNCName(void) { #ifdef LIBXML_TREE_ENABLED int mem_base; int ret_val; - xmlChar * value; /* the value to check */ + const xmlChar * value; /* the value to check */ int n_value; int space; /* allow spaces in front and end of the string */ int n_space; @@ -23667,10 +23633,10 @@ test_xmlValidateNCName(void) { value = gen_const_xmlChar_ptr(n_value, 0); space = gen_int(n_space, 1); - ret_val = xmlValidateNCName((const xmlChar *)value, space); + ret_val = xmlValidateNCName(value, space); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); des_int(n_space, space, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23698,7 +23664,7 @@ test_xmlValidateNMToken(void) { #ifdef LIBXML_TREE_ENABLED int mem_base; int ret_val; - xmlChar * value; /* the value to check */ + const xmlChar * value; /* the value to check */ int n_value; int space; /* allow spaces in front and end of the string */ int n_space; @@ -23709,10 +23675,10 @@ test_xmlValidateNMToken(void) { value = gen_const_xmlChar_ptr(n_value, 0); space = gen_int(n_space, 1); - ret_val = xmlValidateNMToken((const xmlChar *)value, space); + ret_val = xmlValidateNMToken(value, space); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); des_int(n_space, space, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23741,7 +23707,7 @@ test_xmlValidateName(void) { #ifdef LIBXML_TREE_ENABLED int mem_base; int ret_val; - xmlChar * value; /* the value to check */ + const xmlChar * value; /* the value to check */ int n_value; int space; /* allow spaces in front and end of the string */ int n_space; @@ -23752,10 +23718,10 @@ test_xmlValidateName(void) { value = gen_const_xmlChar_ptr(n_value, 0); space = gen_int(n_space, 1); - ret_val = xmlValidateName((const xmlChar *)value, space); + ret_val = xmlValidateName(value, space); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); des_int(n_space, space, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23784,7 +23750,7 @@ test_xmlValidateQName(void) { #ifdef LIBXML_TREE_ENABLED int mem_base; int ret_val; - xmlChar * value; /* the value to check */ + const xmlChar * value; /* the value to check */ int n_value; int space; /* allow spaces in front and end of the string */ int n_space; @@ -23795,10 +23761,10 @@ test_xmlValidateQName(void) { value = gen_const_xmlChar_ptr(n_value, 0); space = gen_int(n_space, 1); - ret_val = xmlValidateQName((const xmlChar *)value, space); + ret_val = xmlValidateQName(value, space); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); des_int(n_space, space, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -23990,9 +23956,9 @@ test_xmlBuildRelativeURI(void) { int mem_base; xmlChar * ret_val; - xmlChar * URI; /* the URI reference under consideration */ + const xmlChar * URI; /* the URI reference under consideration */ int n_URI; - xmlChar * base; /* the base value */ + const xmlChar * base; /* the base value */ int n_base; for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { @@ -24001,11 +23967,11 @@ test_xmlBuildRelativeURI(void) { URI = gen_const_xmlChar_ptr(n_URI, 0); base = gen_const_xmlChar_ptr(n_base, 1); - ret_val = xmlBuildRelativeURI((const xmlChar *)URI, (const xmlChar *)base); + ret_val = xmlBuildRelativeURI(URI, base); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); - des_const_xmlChar_ptr(n_base, (const xmlChar *)base, 1); + des_const_xmlChar_ptr(n_URI, URI, 0); + des_const_xmlChar_ptr(n_base, base, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBuildRelativeURI", @@ -24029,9 +23995,9 @@ test_xmlBuildURI(void) { int mem_base; xmlChar * ret_val; - xmlChar * URI; /* the URI instance found in the document */ + const xmlChar * URI; /* the URI instance found in the document */ int n_URI; - xmlChar * base; /* the base value */ + const xmlChar * base; /* the base value */ int n_base; for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { @@ -24040,11 +24006,11 @@ test_xmlBuildURI(void) { URI = gen_const_xmlChar_ptr(n_URI, 0); base = gen_const_xmlChar_ptr(n_base, 1); - ret_val = xmlBuildURI((const xmlChar *)URI, (const xmlChar *)base); + ret_val = xmlBuildURI(URI, base); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_URI, (const xmlChar *)URI, 0); - des_const_xmlChar_ptr(n_base, (const xmlChar *)base, 1); + des_const_xmlChar_ptr(n_URI, URI, 0); + des_const_xmlChar_ptr(n_base, base, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlBuildURI", @@ -24068,17 +24034,17 @@ test_xmlCanonicPath(void) { int mem_base; xmlChar * ret_val; - xmlChar * path; /* the resource locator in a filesystem notation */ + const xmlChar * path; /* the resource locator in a filesystem notation */ int n_path; for (n_path = 0;n_path < gen_nb_const_xmlChar_ptr;n_path++) { mem_base = xmlMemBlocks(); path = gen_const_xmlChar_ptr(n_path, 0); - ret_val = xmlCanonicPath((const xmlChar *)path); + ret_val = xmlCanonicPath(path); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_path, (const xmlChar *)path, 0); + des_const_xmlChar_ptr(n_path, path, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCanonicPath", @@ -24168,7 +24134,7 @@ test_xmlParseURIReference(void) { int ret_val; xmlURIPtr uri; /* pointer to an URI structure */ int n_uri; - char * str; /* the string to analyze */ + const char * str; /* the string to analyze */ int n_str; for (n_uri = 0;n_uri < gen_nb_xmlURIPtr;n_uri++) { @@ -24177,11 +24143,11 @@ test_xmlParseURIReference(void) { uri = gen_xmlURIPtr(n_uri, 0); str = gen_const_char_ptr(n_str, 1); - ret_val = xmlParseURIReference(uri, (const char *)str); + ret_val = xmlParseURIReference(uri, str); desret_int(ret_val); call_tests++; des_xmlURIPtr(n_uri, uri, 0); - des_const_char_ptr(n_str, (const char *)str, 1); + des_const_char_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParseURIReference", @@ -24205,17 +24171,17 @@ test_xmlPathToURI(void) { int mem_base; xmlChar * ret_val; - xmlChar * path; /* the resource locator in a filesystem notation */ + const xmlChar * path; /* the resource locator in a filesystem notation */ int n_path; for (n_path = 0;n_path < gen_nb_const_xmlChar_ptr;n_path++) { mem_base = xmlMemBlocks(); path = gen_const_xmlChar_ptr(n_path, 0); - ret_val = xmlPathToURI((const xmlChar *)path); + ret_val = xmlPathToURI(path); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_path, (const xmlChar *)path, 0); + des_const_xmlChar_ptr(n_path, path, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlPathToURI", @@ -24306,17 +24272,17 @@ test_xmlURIEscape(void) { int mem_base; xmlChar * ret_val; - xmlChar * str; /* the string of the URI to escape */ + const xmlChar * str; /* the string of the URI to escape */ int n_str; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { mem_base = xmlMemBlocks(); str = gen_const_xmlChar_ptr(n_str, 0); - ret_val = xmlURIEscape((const xmlChar *)str); + ret_val = xmlURIEscape(str); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlURIEscape", @@ -24338,9 +24304,9 @@ test_xmlURIEscapeStr(void) { int mem_base; xmlChar * ret_val; - xmlChar * str; /* string to escape */ + const xmlChar * str; /* string to escape */ int n_str; - xmlChar * list; /* exception list string of chars not to escape */ + const xmlChar * list; /* exception list string of chars not to escape */ int n_list; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { @@ -24349,11 +24315,11 @@ test_xmlURIEscapeStr(void) { str = gen_const_xmlChar_ptr(n_str, 0); list = gen_const_xmlChar_ptr(n_list, 1); - ret_val = xmlURIEscapeStr((const xmlChar *)str, (const xmlChar *)list); + ret_val = xmlURIEscapeStr(str, list); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); - des_const_xmlChar_ptr(n_list, (const xmlChar *)list, 1); + des_const_xmlChar_ptr(n_str, str, 0); + des_const_xmlChar_ptr(n_list, list, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlURIEscapeStr", @@ -24415,17 +24381,17 @@ test_xmlAddAttributeDecl(void) { int n_ctxt; xmlDtdPtr dtd; /* pointer to the DTD */ int n_dtd; - xmlChar * elem; /* the element name */ + const xmlChar * elem; /* the element name */ int n_elem; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; - xmlChar * ns; /* the attribute namespace prefix */ + const xmlChar * ns; /* the attribute namespace prefix */ int n_ns; xmlAttributeType type; /* the attribute type */ int n_type; xmlAttributeDefault def; /* the attribute default type */ int n_def; - xmlChar * defaultValue; /* the attribute default value */ + const xmlChar * defaultValue; /* the attribute default value */ int n_defaultValue; xmlEnumerationPtr tree; /* if it's an enumeration, the associated list */ int n_tree; @@ -24450,17 +24416,17 @@ test_xmlAddAttributeDecl(void) { defaultValue = gen_const_xmlChar_ptr(n_defaultValue, 7); tree = gen_xmlEnumerationPtr(n_tree, 8); - ret_val = xmlAddAttributeDecl(ctxt, dtd, (const xmlChar *)elem, (const xmlChar *)name, (const xmlChar *)ns, type, def, (const xmlChar *)defaultValue, tree); + ret_val = xmlAddAttributeDecl(ctxt, dtd, elem, name, ns, type, def, defaultValue, tree); desret_xmlAttributePtr(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDtdPtr(n_dtd, dtd, 1); - des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 2); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 3); - des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 4); + des_const_xmlChar_ptr(n_elem, elem, 2); + des_const_xmlChar_ptr(n_name, name, 3); + des_const_xmlChar_ptr(n_ns, ns, 4); des_xmlAttributeType(n_type, type, 5); des_xmlAttributeDefault(n_def, def, 6); - des_const_xmlChar_ptr(n_defaultValue, (const xmlChar *)defaultValue, 7); + des_const_xmlChar_ptr(n_defaultValue, defaultValue, 7); des_xmlEnumerationPtr(n_tree, tree, 8); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -24503,7 +24469,7 @@ test_xmlAddElementDecl(void) { int n_ctxt; xmlDtdPtr dtd; /* pointer to the DTD */ int n_dtd; - xmlChar * name; /* the entity name */ + const xmlChar * name; /* the entity name */ int n_name; xmlElementTypeVal type; /* the element type */ int n_type; @@ -24522,12 +24488,12 @@ test_xmlAddElementDecl(void) { type = gen_xmlElementTypeVal(n_type, 3); content = gen_xmlElementContentPtr(n_content, 4); - ret_val = xmlAddElementDecl(ctxt, dtd, (const xmlChar *)name, type, content); + ret_val = xmlAddElementDecl(ctxt, dtd, name, type, content); desret_xmlElementPtr(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDtdPtr(n_dtd, dtd, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_name, name, 2); des_xmlElementTypeVal(n_type, type, 3); des_xmlElementContentPtr(n_content, content, 4); xmlResetLastError(); @@ -24970,9 +24936,9 @@ test_xmlGetDtdAttrDesc(void) { xmlAttributePtr ret_val; xmlDtdPtr dtd; /* a pointer to the DtD to search */ int n_dtd; - xmlChar * elem; /* the element name */ + const xmlChar * elem; /* the element name */ int n_elem; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { @@ -24983,12 +24949,12 @@ test_xmlGetDtdAttrDesc(void) { elem = gen_const_xmlChar_ptr(n_elem, 1); name = gen_const_xmlChar_ptr(n_name, 2); - ret_val = xmlGetDtdAttrDesc(dtd, (const xmlChar *)elem, (const xmlChar *)name); + ret_val = xmlGetDtdAttrDesc(dtd, elem, name); desret_xmlAttributePtr(ret_val); call_tests++; des_xmlDtdPtr(n_dtd, dtd, 0); - des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_elem, elem, 1); + des_const_xmlChar_ptr(n_name, name, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetDtdAttrDesc", @@ -25016,7 +24982,7 @@ test_xmlGetDtdElementDesc(void) { xmlElementPtr ret_val; xmlDtdPtr dtd; /* a pointer to the DtD to search */ int n_dtd; - xmlChar * name; /* the element name */ + const xmlChar * name; /* the element name */ int n_name; for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { @@ -25025,11 +24991,11 @@ test_xmlGetDtdElementDesc(void) { dtd = gen_xmlDtdPtr(n_dtd, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlGetDtdElementDesc(dtd, (const xmlChar *)name); + ret_val = xmlGetDtdElementDesc(dtd, name); desret_xmlElementPtr(ret_val); call_tests++; des_xmlDtdPtr(n_dtd, dtd, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetDtdElementDesc", @@ -25065,11 +25031,11 @@ test_xmlGetDtdQAttrDesc(void) { xmlAttributePtr ret_val; xmlDtdPtr dtd; /* a pointer to the DtD to search */ int n_dtd; - xmlChar * elem; /* the element name */ + const xmlChar * elem; /* the element name */ int n_elem; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; - xmlChar * prefix; /* the attribute namespace prefix */ + const xmlChar * prefix; /* the attribute namespace prefix */ int n_prefix; for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { @@ -25082,13 +25048,13 @@ test_xmlGetDtdQAttrDesc(void) { name = gen_const_xmlChar_ptr(n_name, 2); prefix = gen_const_xmlChar_ptr(n_prefix, 3); - ret_val = xmlGetDtdQAttrDesc(dtd, (const xmlChar *)elem, (const xmlChar *)name, (const xmlChar *)prefix); + ret_val = xmlGetDtdQAttrDesc(dtd, elem, name, prefix); desret_xmlAttributePtr(ret_val); call_tests++; des_xmlDtdPtr(n_dtd, dtd, 0); - des_const_xmlChar_ptr(n_elem, (const xmlChar *)elem, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 3); + des_const_xmlChar_ptr(n_elem, elem, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_prefix, prefix, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetDtdQAttrDesc", @@ -25118,9 +25084,9 @@ test_xmlGetDtdQElementDesc(void) { xmlElementPtr ret_val; xmlDtdPtr dtd; /* a pointer to the DtD to search */ int n_dtd; - xmlChar * name; /* the element name */ + const xmlChar * name; /* the element name */ int n_name; - xmlChar * prefix; /* the element namespace prefix */ + const xmlChar * prefix; /* the element namespace prefix */ int n_prefix; for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { @@ -25131,12 +25097,12 @@ test_xmlGetDtdQElementDesc(void) { name = gen_const_xmlChar_ptr(n_name, 1); prefix = gen_const_xmlChar_ptr(n_prefix, 2); - ret_val = xmlGetDtdQElementDesc(dtd, (const xmlChar *)name, (const xmlChar *)prefix); + ret_val = xmlGetDtdQElementDesc(dtd, name, prefix); desret_xmlElementPtr(ret_val); call_tests++; des_xmlDtdPtr(n_dtd, dtd, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_prefix, prefix, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetDtdQElementDesc", @@ -25164,7 +25130,7 @@ test_xmlGetID(void) { xmlAttrPtr ret_val; xmlDocPtr doc; /* pointer to the document */ int n_doc; - xmlChar * ID; /* the ID value */ + const xmlChar * ID; /* the ID value */ int n_ID; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -25173,11 +25139,11 @@ test_xmlGetID(void) { doc = gen_xmlDocPtr(n_doc, 0); ID = gen_const_xmlChar_ptr(n_ID, 1); - ret_val = xmlGetID(doc, (const xmlChar *)ID); + ret_val = xmlGetID(doc, ID); desret_xmlAttrPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_ID, (const xmlChar *)ID, 1); + des_const_xmlChar_ptr(n_ID, ID, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlGetID", @@ -25259,7 +25225,7 @@ test_xmlIsMixedElement(void) { int ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * name; /* the element name */ + const xmlChar * name; /* the element name */ int n_name; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -25268,11 +25234,11 @@ test_xmlIsMixedElement(void) { doc = gen_xmlDocPtr(n_doc, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlIsMixedElement(doc, (const xmlChar *)name); + ret_val = xmlIsMixedElement(doc, name); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlIsMixedElement", @@ -25344,7 +25310,7 @@ test_xmlNewDocElementContent(void) { xmlElementContentPtr ret_val; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * name; /* the subelement name or NULL */ + const xmlChar * name; /* the subelement name or NULL */ int n_name; xmlElementContentType type; /* the type of element content decl */ int n_type; @@ -25357,12 +25323,12 @@ test_xmlNewDocElementContent(void) { name = gen_const_xmlChar_ptr(n_name, 1); type = gen_xmlElementContentType(n_type, 2); - ret_val = xmlNewDocElementContent(doc, (const xmlChar *)name, type); + ret_val = xmlNewDocElementContent(doc, name, type); xmlFreeDocElementContent(doc, ret_val); ret_val = NULL; desret_xmlElementContentPtr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_xmlElementContentType(n_type, type, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -25389,7 +25355,7 @@ test_xmlNewElementContent(void) { int mem_base; xmlElementContentPtr ret_val; - xmlChar * name; /* the subelement name or NULL */ + const xmlChar * name; /* the subelement name or NULL */ int n_name; xmlElementContentType type; /* the type of element content decl */ int n_type; @@ -25400,10 +25366,10 @@ test_xmlNewElementContent(void) { name = gen_const_xmlChar_ptr(n_name, 0); type = gen_xmlElementContentType(n_type, 1); - ret_val = xmlNewElementContent((const xmlChar *)name, type); + ret_val = xmlNewElementContent(name, type); desret_xmlElementContentPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); des_xmlElementContentType(n_type, type, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -25663,9 +25629,9 @@ test_xmlValidCtxtNormalizeAttributeValue(void) { int n_doc; xmlNodePtr elem; /* the parent */ int n_elem; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; - xmlChar * value; /* the attribute value */ + const xmlChar * value; /* the attribute value */ int n_value; for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { @@ -25680,14 +25646,14 @@ test_xmlValidCtxtNormalizeAttributeValue(void) { name = gen_const_xmlChar_ptr(n_name, 3); value = gen_const_xmlChar_ptr(n_value, 4); - ret_val = xmlValidCtxtNormalizeAttributeValue(ctxt, doc, elem, (const xmlChar *)name, (const xmlChar *)value); + ret_val = xmlValidCtxtNormalizeAttributeValue(ctxt, doc, elem, name, value); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_elem, elem, 2); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 3); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 4); + des_const_xmlChar_ptr(n_name, name, 3); + des_const_xmlChar_ptr(n_value, value, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidCtxtNormalizeAttributeValue", @@ -25726,7 +25692,7 @@ test_xmlValidGetPotentialChildren(void) { int ret_val; xmlElementContent * ctree; /* an element content tree */ int n_ctree; - xmlChar ** names; /* an array to store the list of child names */ + const xmlChar ** names; /* an array to store the list of child names */ int n_names; int * len; /* a pointer to the number of element in the list */ int n_len; @@ -25743,11 +25709,11 @@ test_xmlValidGetPotentialChildren(void) { len = gen_int_ptr(n_len, 2); max = gen_int(n_max, 3); - ret_val = xmlValidGetPotentialChildren(ctree, (const xmlChar **)names, len, max); + ret_val = xmlValidGetPotentialChildren(ctree, names, len, max); desret_int(ret_val); call_tests++; des_xmlElementContent_ptr(n_ctree, ctree, 0); - des_const_xmlChar_ptr_ptr(n_names, (const xmlChar **)names, 1); + des_const_xmlChar_ptr_ptr(n_names, names, 1); des_int_ptr(n_len, len, 2); des_int(n_max, max, 3); xmlResetLastError(); @@ -25785,7 +25751,7 @@ test_xmlValidGetValidElements(void) { int n_prev; xmlNode * next; /* an element to insert next */ int n_next; - xmlChar ** names; /* an array to store the list of child names */ + const xmlChar ** names; /* an array to store the list of child names */ int n_names; int max; /* the size of the array */ int n_max; @@ -25800,12 +25766,12 @@ test_xmlValidGetValidElements(void) { names = gen_const_xmlChar_ptr_ptr(n_names, 2); max = gen_int(n_max, 3); - ret_val = xmlValidGetValidElements(prev, next, (const xmlChar **)names, max); + ret_val = xmlValidGetValidElements(prev, next, names, max); desret_int(ret_val); call_tests++; des_xmlNodePtr(n_prev, prev, 0); des_xmlNodePtr(n_next, next, 1); - des_const_xmlChar_ptr_ptr(n_names, (const xmlChar **)names, 2); + des_const_xmlChar_ptr_ptr(n_names, names, 2); des_int(n_max, max, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -25841,9 +25807,9 @@ test_xmlValidNormalizeAttributeValue(void) { int n_doc; xmlNodePtr elem; /* the parent */ int n_elem; - xmlChar * name; /* the attribute name */ + const xmlChar * name; /* the attribute name */ int n_name; - xmlChar * value; /* the attribute value */ + const xmlChar * value; /* the attribute value */ int n_value; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -25856,13 +25822,13 @@ test_xmlValidNormalizeAttributeValue(void) { name = gen_const_xmlChar_ptr(n_name, 2); value = gen_const_xmlChar_ptr(n_value, 3); - ret_val = xmlValidNormalizeAttributeValue(doc, elem, (const xmlChar *)name, (const xmlChar *)value); + ret_val = xmlValidNormalizeAttributeValue(doc, elem, name, value); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); des_xmlNodePtr(n_elem, elem, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_value, value, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidNormalizeAttributeValue", @@ -25942,7 +25908,7 @@ test_xmlValidateAttributeValue(void) { int ret_val; xmlAttributeType type; /* an attribute type */ int n_type; - xmlChar * value; /* an attribute value */ + const xmlChar * value; /* an attribute value */ int n_value; for (n_type = 0;n_type < gen_nb_xmlAttributeType;n_type++) { @@ -25951,11 +25917,11 @@ test_xmlValidateAttributeValue(void) { type = gen_xmlAttributeType(n_type, 0); value = gen_const_xmlChar_ptr(n_value, 1); - ret_val = xmlValidateAttributeValue(type, (const xmlChar *)value); + ret_val = xmlValidateAttributeValue(type, value); desret_int(ret_val); call_tests++; des_xmlAttributeType(n_type, type, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateAttributeValue", @@ -26248,17 +26214,17 @@ test_xmlValidateNameValue(void) { #if defined(LIBXML_VALID_ENABLED) int mem_base; int ret_val; - xmlChar * value; /* an Name value */ + const xmlChar * value; /* an Name value */ int n_value; for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { mem_base = xmlMemBlocks(); value = gen_const_xmlChar_ptr(n_value, 0); - ret_val = xmlValidateNameValue((const xmlChar *)value); + ret_val = xmlValidateNameValue(value); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateNameValue", @@ -26282,17 +26248,17 @@ test_xmlValidateNamesValue(void) { #if defined(LIBXML_VALID_ENABLED) int mem_base; int ret_val; - xmlChar * value; /* an Names value */ + const xmlChar * value; /* an Names value */ int n_value; for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { mem_base = xmlMemBlocks(); value = gen_const_xmlChar_ptr(n_value, 0); - ret_val = xmlValidateNamesValue((const xmlChar *)value); + ret_val = xmlValidateNamesValue(value); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateNamesValue", @@ -26316,17 +26282,17 @@ test_xmlValidateNmtokenValue(void) { #if defined(LIBXML_VALID_ENABLED) int mem_base; int ret_val; - xmlChar * value; /* an Nmtoken value */ + const xmlChar * value; /* an Nmtoken value */ int n_value; for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { mem_base = xmlMemBlocks(); value = gen_const_xmlChar_ptr(n_value, 0); - ret_val = xmlValidateNmtokenValue((const xmlChar *)value); + ret_val = xmlValidateNmtokenValue(value); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateNmtokenValue", @@ -26350,17 +26316,17 @@ test_xmlValidateNmtokensValue(void) { #if defined(LIBXML_VALID_ENABLED) int mem_base; int ret_val; - xmlChar * value; /* an Nmtokens value */ + const xmlChar * value; /* an Nmtokens value */ int n_value; for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { mem_base = xmlMemBlocks(); value = gen_const_xmlChar_ptr(n_value, 0); - ret_val = xmlValidateNmtokensValue((const xmlChar *)value); + ret_val = xmlValidateNmtokensValue(value); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateNmtokensValue", @@ -26436,7 +26402,7 @@ test_xmlValidateNotationUse(void) { int n_ctxt; xmlDocPtr doc; /* the document */ int n_doc; - xmlChar * notationName; /* the notation name to check */ + const xmlChar * notationName; /* the notation name to check */ int n_notationName; for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { @@ -26447,12 +26413,12 @@ test_xmlValidateNotationUse(void) { doc = gen_xmlDocPtr(n_doc, 1); notationName = gen_const_xmlChar_ptr(n_notationName, 2); - ret_val = xmlValidateNotationUse(ctxt, doc, (const xmlChar *)notationName); + ret_val = xmlValidateNotationUse(ctxt, doc, notationName); desret_int(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDocPtr(n_doc, doc, 1); - des_const_xmlChar_ptr(n_notationName, (const xmlChar *)notationName, 2); + des_const_xmlChar_ptr(n_notationName, notationName, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateNotationUse", @@ -26488,7 +26454,7 @@ test_xmlValidateOneAttribute(void) { int n_elem; xmlAttrPtr attr; /* an attribute instance */ int n_attr; - xmlChar * value; /* the attribute value (without entities processing) */ + const xmlChar * value; /* the attribute value (without entities processing) */ int n_value; for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { @@ -26503,14 +26469,14 @@ test_xmlValidateOneAttribute(void) { attr = gen_xmlAttrPtr(n_attr, 3); value = gen_const_xmlChar_ptr(n_value, 4); - ret_val = xmlValidateOneAttribute(ctxt, doc, elem, attr, (const xmlChar *)value); + ret_val = xmlValidateOneAttribute(ctxt, doc, elem, attr, value); desret_int(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_elem, elem, 2); des_xmlAttrPtr(n_attr, attr, 3); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 4); + des_const_xmlChar_ptr(n_value, value, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateOneAttribute", @@ -26596,11 +26562,11 @@ test_xmlValidateOneNamespace(void) { int n_doc; xmlNodePtr elem; /* an element instance */ int n_elem; - xmlChar * prefix; /* the namespace prefix */ + const xmlChar * prefix; /* the namespace prefix */ int n_prefix; xmlNsPtr ns; /* an namespace declaration instance */ int n_ns; - xmlChar * value; /* the attribute value (without entities processing) */ + const xmlChar * value; /* the attribute value (without entities processing) */ int n_value; for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { @@ -26617,15 +26583,15 @@ test_xmlValidateOneNamespace(void) { ns = gen_xmlNsPtr(n_ns, 4); value = gen_const_xmlChar_ptr(n_value, 5); - ret_val = xmlValidateOneNamespace(ctxt, doc, elem, (const xmlChar *)prefix, ns, (const xmlChar *)value); + ret_val = xmlValidateOneNamespace(ctxt, doc, elem, prefix, ns, value); desret_int(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_elem, elem, 2); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 3); + des_const_xmlChar_ptr(n_prefix, prefix, 3); des_xmlNsPtr(n_ns, ns, 4); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 5); + des_const_xmlChar_ptr(n_value, value, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidateOneNamespace", @@ -26665,7 +26631,7 @@ test_xmlValidatePopElement(void) { int n_doc; xmlNodePtr elem; /* an element instance */ int n_elem; - xmlChar * qname; /* the qualified name as appearing in the serialization */ + const xmlChar * qname; /* the qualified name as appearing in the serialization */ int n_qname; for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { @@ -26678,13 +26644,13 @@ test_xmlValidatePopElement(void) { elem = gen_xmlNodePtr(n_elem, 2); qname = gen_const_xmlChar_ptr(n_qname, 3); - ret_val = xmlValidatePopElement(ctxt, doc, elem, (const xmlChar *)qname); + ret_val = xmlValidatePopElement(ctxt, doc, elem, qname); desret_int(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_elem, elem, 2); - des_const_xmlChar_ptr(n_qname, (const xmlChar *)qname, 3); + des_const_xmlChar_ptr(n_qname, qname, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidatePopElement", @@ -26716,7 +26682,7 @@ test_xmlValidatePushCData(void) { int ret_val; xmlValidCtxtPtr ctxt; /* the validation context */ int n_ctxt; - xmlChar * data; /* some character data read */ + const xmlChar * data; /* some character data read */ int n_data; int len; /* the length of the data */ int n_len; @@ -26732,11 +26698,11 @@ test_xmlValidatePushCData(void) { (len > xmlStrlen(BAD_CAST data))) len = 0; - ret_val = xmlValidatePushCData(ctxt, (const xmlChar *)data, len); + ret_val = xmlValidatePushCData(ctxt, data, len); desret_int(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_data, (const xmlChar *)data, 1); + des_const_xmlChar_ptr(n_data, data, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -26771,7 +26737,7 @@ test_xmlValidatePushElement(void) { int n_doc; xmlNodePtr elem; /* an element instance */ int n_elem; - xmlChar * qname; /* the qualified name as appearing in the serialization */ + const xmlChar * qname; /* the qualified name as appearing in the serialization */ int n_qname; for (n_ctxt = 0;n_ctxt < gen_nb_xmlValidCtxtPtr;n_ctxt++) { @@ -26784,13 +26750,13 @@ test_xmlValidatePushElement(void) { elem = gen_xmlNodePtr(n_elem, 2); qname = gen_const_xmlChar_ptr(n_qname, 3); - ret_val = xmlValidatePushElement(ctxt, doc, elem, (const xmlChar *)qname); + ret_val = xmlValidatePushElement(ctxt, doc, elem, qname); desret_int(ret_val); call_tests++; des_xmlValidCtxtPtr(n_ctxt, ctxt, 0); des_xmlDocPtr(n_doc, doc, 1); des_xmlNodePtr(n_elem, elem, 2); - des_const_xmlChar_ptr(n_qname, (const xmlChar *)qname, 3); + des_const_xmlChar_ptr(n_qname, qname, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlValidatePushElement", @@ -27361,17 +27327,17 @@ test_xmlCheckFilename(void) { int mem_base; int ret_val; - char * path; /* the path to check */ + const char * path; /* the path to check */ int n_path; for (n_path = 0;n_path < gen_nb_const_char_ptr;n_path++) { mem_base = xmlMemBlocks(); path = gen_const_char_ptr(n_path, 0); - ret_val = xmlCheckFilename((const char *)path); + ret_val = xmlCheckFilename(path); desret_int(ret_val); call_tests++; - des_const_char_ptr(n_path, (const char *)path, 0); + des_const_char_ptr(n_path, path, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCheckFilename", @@ -27924,7 +27890,7 @@ test_xmlNoNetExternalEntityLoader(void) { xmlParserInputPtr ret_val; const char * URL; /* the URL for the entity to load */ int n_URL; - char * ID; /* the System ID for the entity to load */ + const char * ID; /* the System ID for the entity to load */ int n_ID; xmlParserCtxtPtr ctxt; /* the context in which the entity is called or NULL */ int n_ctxt; @@ -27937,11 +27903,11 @@ test_xmlNoNetExternalEntityLoader(void) { ID = gen_const_char_ptr(n_ID, 1); ctxt = gen_xmlParserCtxtPtr(n_ctxt, 2); - ret_val = xmlNoNetExternalEntityLoader(URL, (const char *)ID, ctxt); + ret_val = xmlNoNetExternalEntityLoader(URL, ID, ctxt); desret_xmlParserInputPtr(ret_val); call_tests++; des_filepath(n_URL, URL, 0); - des_const_char_ptr(n_ID, (const char *)ID, 1); + des_const_char_ptr(n_ID, ID, 1); des_xmlParserCtxtPtr(n_ctxt, ctxt, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -27968,17 +27934,17 @@ test_xmlNormalizeWindowsPath(void) { int mem_base; xmlChar * ret_val; - xmlChar * path; /* the input file path */ + const xmlChar * path; /* the input file path */ int n_path; for (n_path = 0;n_path < gen_nb_const_xmlChar_ptr;n_path++) { mem_base = xmlMemBlocks(); path = gen_const_xmlChar_ptr(n_path, 0); - ret_val = xmlNormalizeWindowsPath((const xmlChar *)path); + ret_val = xmlNormalizeWindowsPath(path); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_path, (const xmlChar *)path, 0); + des_const_xmlChar_ptr(n_path, path, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNormalizeWindowsPath", @@ -28264,7 +28230,7 @@ test_xmlOutputBufferWrite(void) { int n_out; int len; /* the size in bytes of the array. */ int n_len; - char * buf; /* an char array */ + const char * buf; /* an char array */ int n_buf; for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) { @@ -28278,12 +28244,12 @@ test_xmlOutputBufferWrite(void) { (len > xmlStrlen(BAD_CAST buf))) len = 0; - ret_val = xmlOutputBufferWrite(out, len, (const char *)buf); + ret_val = xmlOutputBufferWrite(out, len, buf); desret_int(ret_val); call_tests++; des_xmlOutputBufferPtr(n_out, out, 0); des_int(n_len, len, 1); - des_const_char_ptr(n_buf, (const char *)buf, 2); + des_const_char_ptr(n_buf, buf, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlOutputBufferWrite", @@ -28323,7 +28289,7 @@ test_xmlOutputBufferWriteString(void) { int ret_val; xmlOutputBufferPtr out; /* a buffered parser output */ int n_out; - char * str; /* a zero terminated C string */ + const char * str; /* a zero terminated C string */ int n_str; for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) { @@ -28332,11 +28298,11 @@ test_xmlOutputBufferWriteString(void) { out = gen_xmlOutputBufferPtr(n_out, 0); str = gen_const_char_ptr(n_str, 1); - ret_val = xmlOutputBufferWriteString(out, (const char *)str); + ret_val = xmlOutputBufferWriteString(out, str); desret_int(ret_val); call_tests++; des_xmlOutputBufferPtr(n_out, out, 0); - des_const_char_ptr(n_str, (const char *)str, 1); + des_const_char_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlOutputBufferWriteString", @@ -28499,7 +28465,7 @@ test_xmlParserInputBufferCreateMem(void) { int mem_base; xmlParserInputBufferPtr ret_val; - char * mem; /* the memory input */ + const char * mem; /* the memory input */ int n_mem; int size; /* the length of the memory block */ int n_size; @@ -28517,10 +28483,10 @@ test_xmlParserInputBufferCreateMem(void) { (size > xmlStrlen(BAD_CAST mem))) size = 0; - ret_val = xmlParserInputBufferCreateMem((const char *)mem, size, enc); + ret_val = xmlParserInputBufferCreateMem(mem, size, enc); desret_xmlParserInputBufferPtr(ret_val); call_tests++; - des_const_char_ptr(n_mem, (const char *)mem, 0); + des_const_char_ptr(n_mem, mem, 0); des_int(n_size, size, 1); des_xmlCharEncoding(n_enc, enc, 2); xmlResetLastError(); @@ -28548,7 +28514,7 @@ test_xmlParserInputBufferCreateStatic(void) { int mem_base; xmlParserInputBufferPtr ret_val; - char * mem; /* the memory input */ + const char * mem; /* the memory input */ int n_mem; int size; /* the length of the memory block */ int n_size; @@ -28566,10 +28532,10 @@ test_xmlParserInputBufferCreateStatic(void) { (size > xmlStrlen(BAD_CAST mem))) size = 0; - ret_val = xmlParserInputBufferCreateStatic((const char *)mem, size, enc); + ret_val = xmlParserInputBufferCreateStatic(mem, size, enc); desret_xmlParserInputBufferPtr(ret_val); call_tests++; - des_const_char_ptr(n_mem, (const char *)mem, 0); + des_const_char_ptr(n_mem, mem, 0); des_int(n_size, size, 1); des_xmlCharEncoding(n_enc, enc, 2); xmlResetLastError(); @@ -28640,7 +28606,7 @@ test_xmlParserInputBufferPush(void) { int n_in; int len; /* the size in bytes of the array. */ int n_len; - char * buf; /* an char array */ + const char * buf; /* an char array */ int n_buf; for (n_in = 0;n_in < gen_nb_xmlParserInputBufferPtr;n_in++) { @@ -28654,12 +28620,12 @@ test_xmlParserInputBufferPush(void) { (len > xmlStrlen(BAD_CAST buf))) len = 0; - ret_val = xmlParserInputBufferPush(in, len, (const char *)buf); + ret_val = xmlParserInputBufferPush(in, len, buf); desret_int(ret_val); call_tests++; des_xmlParserInputBufferPtr(n_in, in, 0); des_int(n_len, len, 1); - des_const_char_ptr(n_buf, (const char *)buf, 2); + des_const_char_ptr(n_buf, buf, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParserInputBufferPush", @@ -29284,7 +29250,7 @@ test_xmlCopyError(void) { int mem_base; int ret_val; - xmlError * from; /* a source error */ + const xmlError * from; /* a source error */ int n_from; xmlErrorPtr to; /* a target error */ int n_to; @@ -29295,10 +29261,10 @@ test_xmlCopyError(void) { from = gen_const_xmlError_ptr(n_from, 0); to = gen_xmlErrorPtr(n_to, 1); - ret_val = xmlCopyError((const xmlError *)from, to); + ret_val = xmlCopyError(from, to); desret_int(ret_val); call_tests++; - des_const_xmlError_ptr(n_from, (const xmlError *)from, 0); + des_const_xmlError_ptr(n_from, from, 0); des_xmlErrorPtr(n_to, to, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -29639,7 +29605,7 @@ test_xmlModuleSymbol(void) { int ret_val; xmlModulePtr module; /* the module */ int n_module; - char * name; /* the name of the symbol */ + const char * name; /* the name of the symbol */ int n_name; void ** symbol; /* the resulting symbol address */ int n_symbol; @@ -29652,11 +29618,11 @@ test_xmlModuleSymbol(void) { name = gen_const_char_ptr(n_name, 1); symbol = gen_void_ptr_ptr(n_symbol, 2); - ret_val = xmlModuleSymbol(module, (const char *)name, symbol); + ret_val = xmlModuleSymbol(module, name, symbol); desret_int(ret_val); call_tests++; des_xmlModulePtr(n_module, module, 0); - des_const_char_ptr(n_name, (const char *)name, 1); + des_const_char_ptr(n_name, name, 1); des_void_ptr_ptr(n_symbol, symbol, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -29773,11 +29739,11 @@ test_xmlReaderForDoc(void) { #if defined(LIBXML_READER_ENABLED) int mem_base; xmlTextReaderPtr ret_val; - xmlChar * cur; /* a pointer to a zero terminated string */ + const xmlChar * cur; /* a pointer to a zero terminated string */ int n_cur; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -29792,12 +29758,12 @@ test_xmlReaderForDoc(void) { encoding = gen_const_char_ptr(n_encoding, 2); options = gen_parseroptions(n_options, 3); - ret_val = xmlReaderForDoc((const xmlChar *)cur, URL, (const char *)encoding, options); + ret_val = xmlReaderForDoc(cur, URL, encoding, options); desret_xmlTextReaderPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_xmlChar_ptr(n_cur, cur, 0); des_filepath(n_URL, URL, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_parseroptions(n_options, options, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -29830,7 +29796,7 @@ test_xmlReaderForFile(void) { xmlTextReaderPtr ret_val; const char * filename; /* a file or URL */ int n_filename; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -29843,11 +29809,11 @@ test_xmlReaderForFile(void) { encoding = gen_const_char_ptr(n_encoding, 1); options = gen_parseroptions(n_options, 2); - ret_val = xmlReaderForFile(filename, (const char *)encoding, options); + ret_val = xmlReaderForFile(filename, encoding, options); desret_xmlTextReaderPtr(ret_val); call_tests++; des_filepath(n_filename, filename, 0); - des_const_char_ptr(n_encoding, (const char *)encoding, 1); + des_const_char_ptr(n_encoding, encoding, 1); des_parseroptions(n_options, options, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -29876,13 +29842,13 @@ test_xmlReaderForMemory(void) { #if defined(LIBXML_READER_ENABLED) int mem_base; xmlTextReaderPtr ret_val; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -29902,13 +29868,13 @@ test_xmlReaderForMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlReaderForMemory((const char *)buffer, size, URL, (const char *)encoding, options); + ret_val = xmlReaderForMemory(buffer, size, URL, encoding, options); desret_xmlTextReaderPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); des_filepath(n_URL, URL, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_parseroptions(n_options, options, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -29943,11 +29909,11 @@ test_xmlReaderNewDoc(void) { int ret_val; xmlTextReaderPtr reader; /* an XML reader */ int n_reader; - xmlChar * cur; /* a pointer to a zero terminated string */ + const xmlChar * cur; /* a pointer to a zero terminated string */ int n_cur; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -29964,13 +29930,13 @@ test_xmlReaderNewDoc(void) { encoding = gen_const_char_ptr(n_encoding, 3); options = gen_parseroptions(n_options, 4); - ret_val = xmlReaderNewDoc(reader, (const xmlChar *)cur, URL, (const char *)encoding, options); + ret_val = xmlReaderNewDoc(reader, cur, URL, encoding, options); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 1); + des_const_xmlChar_ptr(n_cur, cur, 1); des_filepath(n_URL, URL, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_parseroptions(n_options, options, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -30007,7 +29973,7 @@ test_xmlReaderNewFile(void) { int n_reader; const char * filename; /* a file or URL */ int n_filename; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -30022,12 +29988,12 @@ test_xmlReaderNewFile(void) { encoding = gen_const_char_ptr(n_encoding, 2); options = gen_parseroptions(n_options, 3); - ret_val = xmlReaderNewFile(reader, filename, (const char *)encoding, options); + ret_val = xmlReaderNewFile(reader, filename, encoding, options); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); des_filepath(n_filename, filename, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); + des_const_char_ptr(n_encoding, encoding, 2); des_parseroptions(n_options, options, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -30060,13 +30026,13 @@ test_xmlReaderNewMemory(void) { int ret_val; xmlTextReaderPtr reader; /* an XML reader */ int n_reader; - char * buffer; /* a pointer to a char array */ + const char * buffer; /* a pointer to a char array */ int n_buffer; int size; /* the size of the array */ int n_size; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -30088,14 +30054,14 @@ test_xmlReaderNewMemory(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlReaderNewMemory(reader, (const char *)buffer, size, URL, (const char *)encoding, options); + ret_val = xmlReaderNewMemory(reader, buffer, size, URL, encoding, options); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_char_ptr(n_buffer, (const char *)buffer, 1); + des_const_char_ptr(n_buffer, buffer, 1); des_int(n_size, size, 2); des_filepath(n_URL, URL, 3); - des_const_char_ptr(n_encoding, (const char *)encoding, 4); + des_const_char_ptr(n_encoding, encoding, 4); des_parseroptions(n_options, options, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -30547,7 +30513,7 @@ test_xmlTextReaderConstString(void) { const xmlChar * ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - xmlChar * str; /* the string to intern. */ + const xmlChar * str; /* the string to intern. */ int n_str; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -30556,11 +30522,11 @@ test_xmlTextReaderConstString(void) { reader = gen_xmlTextReaderPtr(n_reader, 0); str = gen_const_xmlChar_ptr(n_str, 1); - ret_val = xmlTextReaderConstString(reader, (const xmlChar *)str); + ret_val = xmlTextReaderConstString(reader, str); desret_const_xmlChar_ptr(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderConstString", @@ -30826,7 +30792,7 @@ test_xmlTextReaderGetAttribute(void) { xmlChar * ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - xmlChar * name; /* the qualified name of the attribute. */ + const xmlChar * name; /* the qualified name of the attribute. */ int n_name; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -30835,11 +30801,11 @@ test_xmlTextReaderGetAttribute(void) { reader = gen_xmlTextReaderPtr(n_reader, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlTextReaderGetAttribute(reader, (const xmlChar *)name); + ret_val = xmlTextReaderGetAttribute(reader, name); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderGetAttribute", @@ -30908,9 +30874,9 @@ test_xmlTextReaderGetAttributeNs(void) { xmlChar * ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - xmlChar * localName; /* the local name of the attribute. */ + const xmlChar * localName; /* the local name of the attribute. */ int n_localName; - xmlChar * namespaceURI; /* the namespace URI of the attribute. */ + const xmlChar * namespaceURI; /* the namespace URI of the attribute. */ int n_namespaceURI; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -30921,12 +30887,12 @@ test_xmlTextReaderGetAttributeNs(void) { localName = gen_const_xmlChar_ptr(n_localName, 1); namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 2); - ret_val = xmlTextReaderGetAttributeNs(reader, (const xmlChar *)localName, (const xmlChar *)namespaceURI); + ret_val = xmlTextReaderGetAttributeNs(reader, localName, namespaceURI); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_localName, (const xmlChar *)localName, 1); - des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 2); + des_const_xmlChar_ptr(n_localName, localName, 1); + des_const_xmlChar_ptr(n_namespaceURI, namespaceURI, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderGetAttributeNs", @@ -31465,7 +31431,7 @@ test_xmlTextReaderLookupNamespace(void) { xmlChar * ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - xmlChar * prefix; /* the prefix whose namespace URI is to be resolved. To return the default namespace, specify NULL */ + const xmlChar * prefix; /* the prefix whose namespace URI is to be resolved. To return the default namespace, specify NULL */ int n_prefix; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -31474,11 +31440,11 @@ test_xmlTextReaderLookupNamespace(void) { reader = gen_xmlTextReaderPtr(n_reader, 0); prefix = gen_const_xmlChar_ptr(n_prefix, 1); - ret_val = xmlTextReaderLookupNamespace(reader, (const xmlChar *)prefix); + ret_val = xmlTextReaderLookupNamespace(reader, prefix); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_prefix, prefix, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderLookupNamespace", @@ -31506,7 +31472,7 @@ test_xmlTextReaderMoveToAttribute(void) { int ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - xmlChar * name; /* the qualified name of the attribute. */ + const xmlChar * name; /* the qualified name of the attribute. */ int n_name; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -31515,11 +31481,11 @@ test_xmlTextReaderMoveToAttribute(void) { reader = gen_xmlTextReaderPtr(n_reader, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlTextReaderMoveToAttribute(reader, (const xmlChar *)name); + ret_val = xmlTextReaderMoveToAttribute(reader, name); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderMoveToAttribute", @@ -31588,9 +31554,9 @@ test_xmlTextReaderMoveToAttributeNs(void) { int ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - xmlChar * localName; /* the local name of the attribute. */ + const xmlChar * localName; /* the local name of the attribute. */ int n_localName; - xmlChar * namespaceURI; /* the namespace URI of the attribute. */ + const xmlChar * namespaceURI; /* the namespace URI of the attribute. */ int n_namespaceURI; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -31601,12 +31567,12 @@ test_xmlTextReaderMoveToAttributeNs(void) { localName = gen_const_xmlChar_ptr(n_localName, 1); namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 2); - ret_val = xmlTextReaderMoveToAttributeNs(reader, (const xmlChar *)localName, (const xmlChar *)namespaceURI); + ret_val = xmlTextReaderMoveToAttributeNs(reader, localName, namespaceURI); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_localName, (const xmlChar *)localName, 1); - des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 2); + des_const_xmlChar_ptr(n_localName, localName, 1); + des_const_xmlChar_ptr(n_namespaceURI, namespaceURI, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderMoveToAttributeNs", @@ -32011,9 +31977,9 @@ test_xmlTextReaderPreservePattern(void) { int ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - xmlChar * pattern; /* an XPath subset pattern */ + const xmlChar * pattern; /* an XPath subset pattern */ int n_pattern; - xmlChar ** namespaces; /* the prefix definitions, array of [URI, prefix] or NULL */ + const xmlChar ** namespaces; /* the prefix definitions, array of [URI, prefix] or NULL */ int n_namespaces; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -32024,12 +31990,12 @@ test_xmlTextReaderPreservePattern(void) { pattern = gen_const_xmlChar_ptr(n_pattern, 1); namespaces = gen_const_xmlChar_ptr_ptr(n_namespaces, 2); - ret_val = xmlTextReaderPreservePattern(reader, (const xmlChar *)pattern, (const xmlChar **)namespaces); + ret_val = xmlTextReaderPreservePattern(reader, pattern, namespaces); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_xmlChar_ptr(n_pattern, (const xmlChar *)pattern, 1); - des_const_xmlChar_ptr_ptr(n_namespaces, (const xmlChar **)namespaces, 2); + des_const_xmlChar_ptr(n_pattern, pattern, 1); + des_const_xmlChar_ptr_ptr(n_namespaces, namespaces, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderPreservePattern", @@ -32237,7 +32203,7 @@ test_xmlTextReaderRelaxNGValidate(void) { int ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - char * rng; /* the path to a RelaxNG schema or NULL */ + const char * rng; /* the path to a RelaxNG schema or NULL */ int n_rng; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -32246,11 +32212,11 @@ test_xmlTextReaderRelaxNGValidate(void) { reader = gen_xmlTextReaderPtr(n_reader, 0); rng = gen_const_char_ptr(n_rng, 1); - ret_val = xmlTextReaderRelaxNGValidate(reader, (const char *)rng); + ret_val = xmlTextReaderRelaxNGValidate(reader, rng); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_char_ptr(n_rng, (const char *)rng, 1); + des_const_char_ptr(n_rng, rng, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextReaderRelaxNGValidate", @@ -32325,7 +32291,7 @@ test_xmlTextReaderSchemaValidate(void) { int ret_val; xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */ int n_reader; - char * xsd; /* the path to a W3C XSD schema or NULL */ + const char * xsd; /* the path to a W3C XSD schema or NULL */ int n_xsd; for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) { @@ -32333,11 +32299,11 @@ test_xmlTextReaderSchemaValidate(void) { reader = gen_xmlTextReaderPtr(n_reader, 0); xsd = gen_const_char_ptr(n_xsd, 1); - ret_val = xmlTextReaderSchemaValidate(reader, (const char *)xsd); + ret_val = xmlTextReaderSchemaValidate(reader, xsd); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); - des_const_char_ptr(n_xsd, (const char *)xsd, 1); + des_const_char_ptr(n_xsd, xsd, 1); xmlResetLastError(); } } @@ -32528,7 +32494,7 @@ test_xmlTextReaderSetup(void) { int n_input; const char * URL; /* the base URL to use for the document */ int n_URL; - char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -32545,12 +32511,12 @@ test_xmlTextReaderSetup(void) { encoding = gen_const_char_ptr(n_encoding, 3); options = gen_parseroptions(n_options, 4); - ret_val = xmlTextReaderSetup(reader, input, URL, (const char *)encoding, options); + ret_val = xmlTextReaderSetup(reader, input, URL, encoding, options); desret_int(ret_val); call_tests++; des_xmlTextReaderPtr(n_reader, reader, 0); des_filepath(n_URL, URL, 2); - des_const_char_ptr(n_encoding, (const char *)encoding, 3); + des_const_char_ptr(n_encoding, encoding, 3); des_parseroptions(n_options, options, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -32895,7 +32861,7 @@ test_xmlExpGetLanguage(void) { int n_ctxt; xmlExpNodePtr exp; /* the expression */ int n_exp; - xmlChar ** langList; /* where to store the tokens */ + const xmlChar ** langList; /* where to store the tokens */ int n_langList; int len; /* the allocated length of @list */ int n_len; @@ -32910,12 +32876,12 @@ test_xmlExpGetLanguage(void) { langList = gen_const_xmlChar_ptr_ptr(n_langList, 2); len = gen_int(n_len, 3); - ret_val = xmlExpGetLanguage(ctxt, exp, (const xmlChar **)langList, len); + ret_val = xmlExpGetLanguage(ctxt, exp, langList, len); desret_int(ret_val); call_tests++; des_xmlExpCtxtPtr(n_ctxt, ctxt, 0); des_xmlExpNodePtr(n_exp, exp, 1); - des_const_xmlChar_ptr_ptr(n_langList, (const xmlChar **)langList, 2); + des_const_xmlChar_ptr_ptr(n_langList, langList, 2); des_int(n_len, len, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -32950,7 +32916,7 @@ test_xmlExpGetStart(void) { int n_ctxt; xmlExpNodePtr exp; /* the expression */ int n_exp; - xmlChar ** tokList; /* where to store the tokens */ + const xmlChar ** tokList; /* where to store the tokens */ int n_tokList; int len; /* the allocated length of @list */ int n_len; @@ -32965,12 +32931,12 @@ test_xmlExpGetStart(void) { tokList = gen_const_xmlChar_ptr_ptr(n_tokList, 2); len = gen_int(n_len, 3); - ret_val = xmlExpGetStart(ctxt, exp, (const xmlChar **)tokList, len); + ret_val = xmlExpGetStart(ctxt, exp, tokList, len); desret_int(ret_val); call_tests++; des_xmlExpCtxtPtr(n_ctxt, ctxt, 0); des_xmlExpNodePtr(n_exp, exp, 1); - des_const_xmlChar_ptr_ptr(n_tokList, (const xmlChar **)tokList, 2); + des_const_xmlChar_ptr_ptr(n_tokList, tokList, 2); des_int(n_len, len, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -33228,7 +33194,7 @@ test_xmlRegExecErrInfo(void) { int ret_val; xmlRegExecCtxtPtr exec; /* a regexp execution context generating an error */ int n_exec; - xmlChar ** string; /* return value for the error string */ + const xmlChar ** string; /* return value for the error string */ int n_string; int * nbval; /* pointer to the number of accepted values IN/OUT */ int n_nbval; @@ -33253,11 +33219,11 @@ test_xmlRegExecErrInfo(void) { values = gen_xmlChar_ptr_ptr(n_values, 4); terminal = gen_int_ptr(n_terminal, 5); - ret_val = xmlRegExecErrInfo(exec, (const xmlChar **)string, nbval, nbneg, values, terminal); + ret_val = xmlRegExecErrInfo(exec, string, nbval, nbneg, values, terminal); desret_int(ret_val); call_tests++; des_xmlRegExecCtxtPtr(n_exec, exec, 0); - des_const_xmlChar_ptr_ptr(n_string, (const xmlChar **)string, 1); + des_const_xmlChar_ptr_ptr(n_string, string, 1); des_int_ptr(n_nbval, nbval, 2); des_int_ptr(n_nbneg, nbneg, 3); des_xmlChar_ptr_ptr(n_values, values, 4); @@ -33359,7 +33325,7 @@ test_xmlRegExecPushString(void) { int ret_val; xmlRegExecCtxtPtr exec; /* a regexp execution context or NULL to indicate the end */ int n_exec; - xmlChar * value; /* a string token input */ + const xmlChar * value; /* a string token input */ int n_value; void * data; /* data associated to the token to reuse in callbacks */ int n_data; @@ -33372,11 +33338,11 @@ test_xmlRegExecPushString(void) { value = gen_const_xmlChar_ptr(n_value, 1); data = gen_userdata(n_data, 2); - ret_val = xmlRegExecPushString(exec, (const xmlChar *)value, data); + ret_val = xmlRegExecPushString(exec, value, data); desret_int(ret_val); call_tests++; des_xmlRegExecCtxtPtr(n_exec, exec, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); des_userdata(n_data, data, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -33407,9 +33373,9 @@ test_xmlRegExecPushString2(void) { int ret_val; xmlRegExecCtxtPtr exec; /* a regexp execution context or NULL to indicate the end */ int n_exec; - xmlChar * value; /* the first string token input */ + const xmlChar * value; /* the first string token input */ int n_value; - xmlChar * value2; /* the second string token input */ + const xmlChar * value2; /* the second string token input */ int n_value2; void * data; /* data associated to the token to reuse in callbacks */ int n_data; @@ -33424,12 +33390,12 @@ test_xmlRegExecPushString2(void) { value2 = gen_const_xmlChar_ptr(n_value2, 2); data = gen_userdata(n_data, 3); - ret_val = xmlRegExecPushString2(exec, (const xmlChar *)value, (const xmlChar *)value2, data); + ret_val = xmlRegExecPushString2(exec, value, value2, data); desret_int(ret_val); call_tests++; des_xmlRegExecCtxtPtr(n_exec, exec, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); - des_const_xmlChar_ptr(n_value2, (const xmlChar *)value2, 2); + des_const_xmlChar_ptr(n_value, value, 1); + des_const_xmlChar_ptr(n_value2, value2, 2); des_userdata(n_data, data, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -33489,7 +33455,7 @@ test_xmlRegexpExec(void) { int ret_val; xmlRegexpPtr comp; /* the compiled regular expression */ int n_comp; - xmlChar * content; /* the value to check against the regular expression */ + const xmlChar * content; /* the value to check against the regular expression */ int n_content; for (n_comp = 0;n_comp < gen_nb_xmlRegexpPtr;n_comp++) { @@ -33498,11 +33464,11 @@ test_xmlRegexpExec(void) { comp = gen_xmlRegexpPtr(n_comp, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlRegexpExec(comp, (const xmlChar *)content); + ret_val = xmlRegexpExec(comp, content); desret_int(ret_val); call_tests++; des_xmlRegexpPtr(n_comp, comp, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlRegexpExec", @@ -33912,17 +33878,17 @@ test_xmlThrDefTreeIndentString(void) { #if defined(LIBXML_OUTPUT_ENABLED) int mem_base; const char * ret_val; - char * v; /* */ + const char * v; /* */ int n_v; for (n_v = 0;n_v < gen_nb_const_char_ptr;n_v++) { mem_base = xmlMemBlocks(); v = gen_const_char_ptr(n_v, 0); - ret_val = xmlThrDefTreeIndentString((const char *)v); + ret_val = xmlThrDefTreeIndentString(v); desret_const_char_ptr(ret_val); call_tests++; - des_const_char_ptr(n_v, (const char *)v, 0); + des_const_char_ptr(n_v, v, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlThrDefTreeIndentString", @@ -34206,7 +34172,7 @@ test_xmlSchemaNewMemParserCtxt(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; xmlSchemaParserCtxtPtr ret_val; - char * buffer; /* a pointer to a char array containing the schemas */ + const char * buffer; /* a pointer to a char array containing the schemas */ int n_buffer; int size; /* the size of the array */ int n_size; @@ -34220,10 +34186,10 @@ test_xmlSchemaNewMemParserCtxt(void) { (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlSchemaNewMemParserCtxt((const char *)buffer, size); + ret_val = xmlSchemaNewMemParserCtxt(buffer, size); desret_xmlSchemaParserCtxtPtr(ret_val); call_tests++; - des_const_char_ptr(n_buffer, (const char *)buffer, 0); + des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -34250,17 +34216,17 @@ test_xmlSchemaNewParserCtxt(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; xmlSchemaParserCtxtPtr ret_val; - char * URL; /* the location of the schema */ + const char * URL; /* the location of the schema */ int n_URL; for (n_URL = 0;n_URL < gen_nb_const_char_ptr;n_URL++) { mem_base = xmlMemBlocks(); URL = gen_const_char_ptr(n_URL, 0); - ret_val = xmlSchemaNewParserCtxt((const char *)URL); + ret_val = xmlSchemaNewParserCtxt(URL); desret_xmlSchemaParserCtxtPtr(ret_val); call_tests++; - des_const_char_ptr(n_URL, (const char *)URL, 0); + des_const_char_ptr(n_URL, URL, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSchemaNewParserCtxt", @@ -34799,7 +34765,7 @@ test_xmlSchemaCheckFacet(void) { int n_typeDecl; xmlSchemaParserCtxtPtr pctxt; /* the schema parser context or NULL */ int n_pctxt; - xmlChar * name; /* the optional name of the type */ + const xmlChar * name; /* the optional name of the type */ int n_name; for (n_facet = 0;n_facet < gen_nb_xmlSchemaFacetPtr;n_facet++) { @@ -34812,13 +34778,13 @@ test_xmlSchemaCheckFacet(void) { pctxt = gen_xmlSchemaParserCtxtPtr(n_pctxt, 2); name = gen_const_xmlChar_ptr(n_name, 3); - ret_val = xmlSchemaCheckFacet(facet, typeDecl, pctxt, (const xmlChar *)name); + ret_val = xmlSchemaCheckFacet(facet, typeDecl, pctxt, name); desret_int(ret_val); call_tests++; des_xmlSchemaFacetPtr(n_facet, facet, 0); des_xmlSchemaTypePtr(n_typeDecl, typeDecl, 1); des_xmlSchemaParserCtxtPtr(n_pctxt, pctxt, 2); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 3); + des_const_xmlChar_ptr(n_name, name, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSchemaCheckFacet", @@ -34865,17 +34831,17 @@ test_xmlSchemaCollapseString(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; xmlChar * ret_val; - xmlChar * value; /* a value */ + const xmlChar * value; /* a value */ int n_value; for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { mem_base = xmlMemBlocks(); value = gen_const_xmlChar_ptr(n_value, 0); - ret_val = xmlSchemaCollapseString((const xmlChar *)value); + ret_val = xmlSchemaCollapseString(value); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSchemaCollapseString", @@ -35073,7 +35039,7 @@ test_xmlSchemaGetCanonValue(void) { int ret_val; xmlSchemaValPtr val; /* the precomputed value */ int n_val; - xmlChar ** retValue; /* the returned value */ + const xmlChar ** retValue; /* the returned value */ int n_retValue; for (n_val = 0;n_val < gen_nb_xmlSchemaValPtr;n_val++) { @@ -35082,11 +35048,11 @@ test_xmlSchemaGetCanonValue(void) { val = gen_xmlSchemaValPtr(n_val, 0); retValue = gen_const_xmlChar_ptr_ptr(n_retValue, 1); - ret_val = xmlSchemaGetCanonValue(val, (const xmlChar **)retValue); + ret_val = xmlSchemaGetCanonValue(val, retValue); desret_int(ret_val); call_tests++; des_xmlSchemaValPtr(n_val, val, 0); - des_const_xmlChar_ptr_ptr(n_retValue, (const xmlChar **)retValue, 1); + des_const_xmlChar_ptr_ptr(n_retValue, retValue, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSchemaGetCanonValue", @@ -35114,7 +35080,7 @@ test_xmlSchemaGetCanonValueWhtsp(void) { int ret_val; xmlSchemaValPtr val; /* the precomputed value */ int n_val; - xmlChar ** retValue; /* the returned value */ + const xmlChar ** retValue; /* the returned value */ int n_retValue; xmlSchemaWhitespaceValueType ws; /* the whitespace type of the value */ int n_ws; @@ -35127,11 +35093,11 @@ test_xmlSchemaGetCanonValueWhtsp(void) { retValue = gen_const_xmlChar_ptr_ptr(n_retValue, 1); ws = gen_xmlSchemaWhitespaceValueType(n_ws, 2); - ret_val = xmlSchemaGetCanonValueWhtsp(val, (const xmlChar **)retValue, ws); + ret_val = xmlSchemaGetCanonValueWhtsp(val, retValue, ws); desret_int(ret_val); call_tests++; des_xmlSchemaValPtr(n_val, val, 0); - des_const_xmlChar_ptr_ptr(n_retValue, (const xmlChar **)retValue, 1); + des_const_xmlChar_ptr_ptr(n_retValue, retValue, 1); des_xmlSchemaWhitespaceValueType(n_ws, ws, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -35194,9 +35160,9 @@ test_xmlSchemaGetPredefinedType(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; xmlSchemaTypePtr ret_val; - xmlChar * name; /* the type name */ + const xmlChar * name; /* the type name */ int n_name; - xmlChar * ns; /* the URI of the namespace usually "http://www.w3.org/2001/XMLSchema" */ + const xmlChar * ns; /* the URI of the namespace usually "http://www.w3.org/2001/XMLSchema" */ int n_ns; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { @@ -35205,11 +35171,11 @@ test_xmlSchemaGetPredefinedType(void) { name = gen_const_xmlChar_ptr(n_name, 0); ns = gen_const_xmlChar_ptr(n_ns, 1); - ret_val = xmlSchemaGetPredefinedType((const xmlChar *)name, (const xmlChar *)ns); + ret_val = xmlSchemaGetPredefinedType(name, ns); desret_xmlSchemaTypePtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); - des_const_xmlChar_ptr(n_ns, (const xmlChar *)ns, 1); + des_const_xmlChar_ptr(n_name, name, 0); + des_const_xmlChar_ptr(n_ns, ns, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSchemaGetPredefinedType", @@ -35378,7 +35344,7 @@ test_xmlSchemaValPredefTypeNode(void) { int ret_val; xmlSchemaTypePtr type; /* the predefined type */ int n_type; - xmlChar * value; /* the value to check */ + const xmlChar * value; /* the value to check */ int n_value; xmlSchemaValPtr * val; /* the return computed value */ int n_val; @@ -35395,11 +35361,11 @@ test_xmlSchemaValPredefTypeNode(void) { val = gen_xmlSchemaValPtr_ptr(n_val, 2); node = gen_xmlNodePtr(n_node, 3); - ret_val = xmlSchemaValPredefTypeNode(type, (const xmlChar *)value, val, node); + ret_val = xmlSchemaValPredefTypeNode(type, value, val, node); desret_int(ret_val); call_tests++; des_xmlSchemaTypePtr(n_type, type, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); des_xmlSchemaValPtr_ptr(n_val, val, 2); des_xmlNodePtr(n_node, node, 3); xmlResetLastError(); @@ -35433,7 +35399,7 @@ test_xmlSchemaValPredefTypeNodeNoNorm(void) { int ret_val; xmlSchemaTypePtr type; /* the predefined type */ int n_type; - xmlChar * value; /* the value to check */ + const xmlChar * value; /* the value to check */ int n_value; xmlSchemaValPtr * val; /* the return computed value */ int n_val; @@ -35450,11 +35416,11 @@ test_xmlSchemaValPredefTypeNodeNoNorm(void) { val = gen_xmlSchemaValPtr_ptr(n_val, 2); node = gen_xmlNodePtr(n_node, 3); - ret_val = xmlSchemaValPredefTypeNodeNoNorm(type, (const xmlChar *)value, val, node); + ret_val = xmlSchemaValPredefTypeNodeNoNorm(type, value, val, node); desret_int(ret_val); call_tests++; des_xmlSchemaTypePtr(n_type, type, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); des_xmlSchemaValPtr_ptr(n_val, val, 2); des_xmlNodePtr(n_node, node, 3); xmlResetLastError(); @@ -35490,7 +35456,7 @@ test_xmlSchemaValidateFacet(void) { int n_base; xmlSchemaFacetPtr facet; /* the facet to check */ int n_facet; - xmlChar * value; /* the lexical repr of the value to validate */ + const xmlChar * value; /* the lexical repr of the value to validate */ int n_value; xmlSchemaValPtr val; /* the precomputed value */ int n_val; @@ -35505,12 +35471,12 @@ test_xmlSchemaValidateFacet(void) { value = gen_const_xmlChar_ptr(n_value, 2); val = gen_xmlSchemaValPtr(n_val, 3); - ret_val = xmlSchemaValidateFacet(base, facet, (const xmlChar *)value, val); + ret_val = xmlSchemaValidateFacet(base, facet, value, val); desret_int(ret_val); call_tests++; des_xmlSchemaTypePtr(n_base, base, 0); des_xmlSchemaFacetPtr(n_facet, facet, 1); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_const_xmlChar_ptr(n_value, value, 2); des_xmlSchemaValPtr(n_val, val, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -35547,7 +35513,7 @@ test_xmlSchemaValidateFacetWhtsp(void) { int n_fws; xmlSchemaValType valType; /* the built-in type of the value */ int n_valType; - xmlChar * value; /* the lexical (or normalized for pattern) repr of the value to validate */ + const xmlChar * value; /* the lexical (or normalized for pattern) repr of the value to validate */ int n_value; xmlSchemaValPtr val; /* the precomputed value */ int n_val; @@ -35568,13 +35534,13 @@ test_xmlSchemaValidateFacetWhtsp(void) { val = gen_xmlSchemaValPtr(n_val, 4); ws = gen_xmlSchemaWhitespaceValueType(n_ws, 5); - ret_val = xmlSchemaValidateFacetWhtsp(facet, fws, valType, (const xmlChar *)value, val, ws); + ret_val = xmlSchemaValidateFacetWhtsp(facet, fws, valType, value, val, ws); desret_int(ret_val); call_tests++; des_xmlSchemaFacetPtr(n_facet, facet, 0); des_xmlSchemaWhitespaceValueType(n_fws, fws, 1); des_xmlSchemaValType(n_valType, valType, 2); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 3); + des_const_xmlChar_ptr(n_value, value, 3); des_xmlSchemaValPtr(n_val, val, 4); des_xmlSchemaWhitespaceValueType(n_ws, ws, 5); xmlResetLastError(); @@ -35614,7 +35580,7 @@ test_xmlSchemaValidateLengthFacet(void) { int n_type; xmlSchemaFacetPtr facet; /* the facet to check */ int n_facet; - xmlChar * value; /* the lexical repr. of the value to be validated */ + const xmlChar * value; /* the lexical repr. of the value to be validated */ int n_value; xmlSchemaValPtr val; /* the precomputed value */ int n_val; @@ -35633,12 +35599,12 @@ test_xmlSchemaValidateLengthFacet(void) { val = gen_xmlSchemaValPtr(n_val, 3); length = gen_unsigned_long_ptr(n_length, 4); - ret_val = xmlSchemaValidateLengthFacet(type, facet, (const xmlChar *)value, val, length); + ret_val = xmlSchemaValidateLengthFacet(type, facet, value, val, length); desret_int(ret_val); call_tests++; des_xmlSchemaTypePtr(n_type, type, 0); des_xmlSchemaFacetPtr(n_facet, facet, 1); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_const_xmlChar_ptr(n_value, value, 2); des_xmlSchemaValPtr(n_val, val, 3); des_unsigned_long_ptr(n_length, length, 4); xmlResetLastError(); @@ -35676,7 +35642,7 @@ test_xmlSchemaValidateLengthFacetWhtsp(void) { int n_facet; xmlSchemaValType valType; /* the built-in type */ int n_valType; - xmlChar * value; /* the lexical repr. of the value to be validated */ + const xmlChar * value; /* the lexical repr. of the value to be validated */ int n_value; xmlSchemaValPtr val; /* the precomputed value */ int n_val; @@ -35699,12 +35665,12 @@ test_xmlSchemaValidateLengthFacetWhtsp(void) { length = gen_unsigned_long_ptr(n_length, 4); ws = gen_xmlSchemaWhitespaceValueType(n_ws, 5); - ret_val = xmlSchemaValidateLengthFacetWhtsp(facet, valType, (const xmlChar *)value, val, length, ws); + ret_val = xmlSchemaValidateLengthFacetWhtsp(facet, valType, value, val, length, ws); desret_int(ret_val); call_tests++; des_xmlSchemaFacetPtr(n_facet, facet, 0); des_xmlSchemaValType(n_valType, valType, 1); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 2); + des_const_xmlChar_ptr(n_value, value, 2); des_xmlSchemaValPtr(n_val, val, 3); des_unsigned_long_ptr(n_length, length, 4); des_xmlSchemaWhitespaceValueType(n_ws, ws, 5); @@ -35743,7 +35709,7 @@ test_xmlSchemaValidateListSimpleTypeFacet(void) { int ret_val; xmlSchemaFacetPtr facet; /* the facet to check */ int n_facet; - xmlChar * value; /* the lexical repr of the value to validate */ + const xmlChar * value; /* the lexical repr of the value to validate */ int n_value; unsigned long actualLen; /* the number of list items */ int n_actualLen; @@ -35760,11 +35726,11 @@ test_xmlSchemaValidateListSimpleTypeFacet(void) { actualLen = gen_unsigned_long(n_actualLen, 2); expectedLen = gen_unsigned_long_ptr(n_expectedLen, 3); - ret_val = xmlSchemaValidateListSimpleTypeFacet(facet, (const xmlChar *)value, actualLen, expectedLen); + ret_val = xmlSchemaValidateListSimpleTypeFacet(facet, value, actualLen, expectedLen); desret_int(ret_val); call_tests++; des_xmlSchemaFacetPtr(n_facet, facet, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); des_unsigned_long(n_actualLen, actualLen, 2); des_unsigned_long_ptr(n_expectedLen, expectedLen, 3); xmlResetLastError(); @@ -35798,7 +35764,7 @@ test_xmlSchemaValidatePredefinedType(void) { int ret_val; xmlSchemaTypePtr type; /* the predefined type */ int n_type; - xmlChar * value; /* the value to check */ + const xmlChar * value; /* the value to check */ int n_value; xmlSchemaValPtr * val; /* the return computed value */ int n_val; @@ -35811,11 +35777,11 @@ test_xmlSchemaValidatePredefinedType(void) { value = gen_const_xmlChar_ptr(n_value, 1); val = gen_xmlSchemaValPtr_ptr(n_val, 2); - ret_val = xmlSchemaValidatePredefinedType(type, (const xmlChar *)value, val); + ret_val = xmlSchemaValidatePredefinedType(type, value, val); desret_int(ret_val); call_tests++; des_xmlSchemaTypePtr(n_type, type, 0); - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 1); + des_const_xmlChar_ptr(n_value, value, 1); des_xmlSchemaValPtr_ptr(n_val, val, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -35963,17 +35929,17 @@ test_xmlSchemaWhiteSpaceReplace(void) { #if defined(LIBXML_SCHEMAS_ENABLED) int mem_base; xmlChar * ret_val; - xmlChar * value; /* a value */ + const xmlChar * value; /* a value */ int n_value; for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { mem_base = xmlMemBlocks(); value = gen_const_xmlChar_ptr(n_value, 0); - ret_val = xmlSchemaWhiteSpaceReplace((const xmlChar *)value); + ret_val = xmlSchemaWhiteSpaceReplace(value); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_value, (const xmlChar *)value, 0); + des_const_xmlChar_ptr(n_value, value, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSchemaWhiteSpaceReplace", @@ -36038,17 +36004,17 @@ test_xmlCharStrdup(void) { int mem_base; xmlChar * ret_val; - char * cur; /* the input char * */ + const char * cur; /* the input char * */ int n_cur; for (n_cur = 0;n_cur < gen_nb_const_char_ptr;n_cur++) { mem_base = xmlMemBlocks(); cur = gen_const_char_ptr(n_cur, 0); - ret_val = xmlCharStrdup((const char *)cur); + ret_val = xmlCharStrdup(cur); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_char_ptr(n_cur, (const char *)cur, 0); + des_const_char_ptr(n_cur, cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCharStrdup", @@ -36070,7 +36036,7 @@ test_xmlCharStrndup(void) { int mem_base; xmlChar * ret_val; - char * cur; /* the input char * */ + const char * cur; /* the input char * */ int n_cur; int len; /* the len of @cur */ int n_len; @@ -36084,10 +36050,10 @@ test_xmlCharStrndup(void) { (len > xmlStrlen(BAD_CAST cur))) len = 0; - ret_val = xmlCharStrndup((const char *)cur, len); + ret_val = xmlCharStrndup(cur, len); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_char_ptr(n_cur, (const char *)cur, 0); + des_const_char_ptr(n_cur, cur, 0); des_int(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36112,17 +36078,17 @@ test_xmlCheckUTF8(void) { int mem_base; int ret_val; - unsigned char * utf; /* Pointer to putative UTF-8 encoded string. */ + const unsigned char * utf; /* Pointer to putative UTF-8 encoded string. */ int n_utf; for (n_utf = 0;n_utf < gen_nb_const_unsigned_char_ptr;n_utf++) { mem_base = xmlMemBlocks(); utf = gen_const_unsigned_char_ptr(n_utf, 0); - ret_val = xmlCheckUTF8((const unsigned char *)utf); + ret_val = xmlCheckUTF8(utf); desret_int(ret_val); call_tests++; - des_const_unsigned_char_ptr(n_utf, (const unsigned char *)utf, 0); + des_const_unsigned_char_ptr(n_utf, utf, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlCheckUTF8", @@ -36144,7 +36110,7 @@ test_xmlGetUTF8Char(void) { int mem_base; int ret_val; - unsigned char * utf; /* a sequence of UTF-8 encoded bytes */ + const unsigned char * utf; /* a sequence of UTF-8 encoded bytes */ int n_utf; int * len; /* a pointer to the minimum number of bytes present in the sequence. This is used to assure the next character is completely contained within the sequence. */ int n_len; @@ -36155,10 +36121,10 @@ test_xmlGetUTF8Char(void) { utf = gen_const_unsigned_char_ptr(n_utf, 0); len = gen_int_ptr(n_len, 1); - ret_val = xmlGetUTF8Char((const unsigned char *)utf, len); + ret_val = xmlGetUTF8Char(utf, len); desret_int(ret_val); call_tests++; - des_const_unsigned_char_ptr(n_utf, (const unsigned char *)utf, 0); + des_const_unsigned_char_ptr(n_utf, utf, 0); des_int_ptr(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36183,9 +36149,9 @@ test_xmlStrEqual(void) { int mem_base; int ret_val; - xmlChar * str1; /* the first xmlChar * */ + const xmlChar * str1; /* the first xmlChar * */ int n_str1; - xmlChar * str2; /* the second xmlChar * */ + const xmlChar * str2; /* the second xmlChar * */ int n_str2; for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { @@ -36194,11 +36160,11 @@ test_xmlStrEqual(void) { str1 = gen_const_xmlChar_ptr(n_str1, 0); str2 = gen_const_xmlChar_ptr(n_str2, 1); - ret_val = xmlStrEqual((const xmlChar *)str1, (const xmlChar *)str2); + ret_val = xmlStrEqual(str1, str2); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); - des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_const_xmlChar_ptr(n_str1, str1, 0); + des_const_xmlChar_ptr(n_str2, str2, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrEqual", @@ -36232,11 +36198,11 @@ test_xmlStrQEqual(void) { int mem_base; int ret_val; - xmlChar * pref; /* the prefix of the QName */ + const xmlChar * pref; /* the prefix of the QName */ int n_pref; - xmlChar * name; /* the localname of the QName */ + const xmlChar * name; /* the localname of the QName */ int n_name; - xmlChar * str; /* the second xmlChar * */ + const xmlChar * str; /* the second xmlChar * */ int n_str; for (n_pref = 0;n_pref < gen_nb_const_xmlChar_ptr;n_pref++) { @@ -36247,12 +36213,12 @@ test_xmlStrQEqual(void) { name = gen_const_xmlChar_ptr(n_name, 1); str = gen_const_xmlChar_ptr(n_str, 2); - ret_val = xmlStrQEqual((const xmlChar *)pref, (const xmlChar *)name, (const xmlChar *)str); + ret_val = xmlStrQEqual(pref, name, str); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_pref, (const xmlChar *)pref, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 2); + des_const_xmlChar_ptr(n_pref, pref, 0); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_str, str, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrQEqual", @@ -36288,9 +36254,9 @@ test_xmlStrcasecmp(void) { int mem_base; int ret_val; - xmlChar * str1; /* the first xmlChar * */ + const xmlChar * str1; /* the first xmlChar * */ int n_str1; - xmlChar * str2; /* the second xmlChar * */ + const xmlChar * str2; /* the second xmlChar * */ int n_str2; for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { @@ -36299,11 +36265,11 @@ test_xmlStrcasecmp(void) { str1 = gen_const_xmlChar_ptr(n_str1, 0); str2 = gen_const_xmlChar_ptr(n_str2, 1); - ret_val = xmlStrcasecmp((const xmlChar *)str1, (const xmlChar *)str2); + ret_val = xmlStrcasecmp(str1, str2); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); - des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_const_xmlChar_ptr(n_str1, str1, 0); + des_const_xmlChar_ptr(n_str2, str2, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrcasecmp", @@ -36327,9 +36293,9 @@ test_xmlStrcasestr(void) { int mem_base; const xmlChar * ret_val; - xmlChar * str; /* the xmlChar * array (haystack) */ + const xmlChar * str; /* the xmlChar * array (haystack) */ int n_str; - xmlChar * val; /* the xmlChar to search (needle) */ + const xmlChar * val; /* the xmlChar to search (needle) */ int n_val; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { @@ -36338,11 +36304,11 @@ test_xmlStrcasestr(void) { str = gen_const_xmlChar_ptr(n_str, 0); val = gen_const_xmlChar_ptr(n_val, 1); - ret_val = xmlStrcasestr((const xmlChar *)str, (const xmlChar *)val); + ret_val = xmlStrcasestr(str, val); desret_const_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); - des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 1); + des_const_xmlChar_ptr(n_str, str, 0); + des_const_xmlChar_ptr(n_val, val, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrcasestr", @@ -36366,7 +36332,7 @@ test_xmlStrchr(void) { int mem_base; const xmlChar * ret_val; - xmlChar * str; /* the xmlChar * array */ + const xmlChar * str; /* the xmlChar * array */ int n_str; xmlChar val; /* the xmlChar to search */ int n_val; @@ -36377,10 +36343,10 @@ test_xmlStrchr(void) { str = gen_const_xmlChar_ptr(n_str, 0); val = gen_xmlChar(n_val, 1); - ret_val = xmlStrchr((const xmlChar *)str, val); + ret_val = xmlStrchr(str, val); desret_const_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); des_xmlChar(n_val, val, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36405,9 +36371,9 @@ test_xmlStrcmp(void) { int mem_base; int ret_val; - xmlChar * str1; /* the first xmlChar * */ + const xmlChar * str1; /* the first xmlChar * */ int n_str1; - xmlChar * str2; /* the second xmlChar * */ + const xmlChar * str2; /* the second xmlChar * */ int n_str2; for (n_str1 = 0;n_str1 < gen_nb_const_xmlChar_ptr;n_str1++) { @@ -36416,11 +36382,11 @@ test_xmlStrcmp(void) { str1 = gen_const_xmlChar_ptr(n_str1, 0); str2 = gen_const_xmlChar_ptr(n_str2, 1); - ret_val = xmlStrcmp((const xmlChar *)str1, (const xmlChar *)str2); + ret_val = xmlStrcmp(str1, str2); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); - des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_const_xmlChar_ptr(n_str1, str1, 0); + des_const_xmlChar_ptr(n_str2, str2, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrcmp", @@ -36444,17 +36410,17 @@ test_xmlStrdup(void) { int mem_base; xmlChar * ret_val; - xmlChar * cur; /* the input xmlChar * */ + const xmlChar * cur; /* the input xmlChar * */ int n_cur; for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { mem_base = xmlMemBlocks(); cur = gen_const_xmlChar_ptr(n_cur, 0); - ret_val = xmlStrdup((const xmlChar *)cur); + ret_val = xmlStrdup(cur); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_xmlChar_ptr(n_cur, cur, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrdup", @@ -36476,17 +36442,17 @@ test_xmlStrlen(void) { int mem_base; int ret_val; - xmlChar * str; /* the xmlChar * array */ + const xmlChar * str; /* the xmlChar * array */ int n_str; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { mem_base = xmlMemBlocks(); str = gen_const_xmlChar_ptr(n_str, 0); - ret_val = xmlStrlen((const xmlChar *)str); + ret_val = xmlStrlen(str); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrlen", @@ -36508,9 +36474,9 @@ test_xmlStrncasecmp(void) { int mem_base; int ret_val; - xmlChar * str1; /* the first xmlChar * */ + const xmlChar * str1; /* the first xmlChar * */ int n_str1; - xmlChar * str2; /* the second xmlChar * */ + const xmlChar * str2; /* the second xmlChar * */ int n_str2; int len; /* the max comparison length */ int n_len; @@ -36526,11 +36492,11 @@ test_xmlStrncasecmp(void) { (len > xmlStrlen(BAD_CAST str2))) len = 0; - ret_val = xmlStrncasecmp((const xmlChar *)str1, (const xmlChar *)str2, len); + ret_val = xmlStrncasecmp(str1, str2, len); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); - des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_const_xmlChar_ptr(n_str1, str1, 0); + des_const_xmlChar_ptr(n_str2, str2, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36557,9 +36523,9 @@ test_xmlStrncatNew(void) { int mem_base; xmlChar * ret_val; - xmlChar * str1; /* first xmlChar string */ + const xmlChar * str1; /* first xmlChar string */ int n_str1; - xmlChar * str2; /* second xmlChar string */ + const xmlChar * str2; /* second xmlChar string */ int n_str2; int len; /* the len of @str2 or < 0 */ int n_len; @@ -36575,11 +36541,11 @@ test_xmlStrncatNew(void) { (len > xmlStrlen(BAD_CAST str2))) len = 0; - ret_val = xmlStrncatNew((const xmlChar *)str1, (const xmlChar *)str2, len); + ret_val = xmlStrncatNew(str1, str2, len); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); - des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_const_xmlChar_ptr(n_str1, str1, 0); + des_const_xmlChar_ptr(n_str2, str2, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36606,9 +36572,9 @@ test_xmlStrncmp(void) { int mem_base; int ret_val; - xmlChar * str1; /* the first xmlChar * */ + const xmlChar * str1; /* the first xmlChar * */ int n_str1; - xmlChar * str2; /* the second xmlChar * */ + const xmlChar * str2; /* the second xmlChar * */ int n_str2; int len; /* the max comparison length */ int n_len; @@ -36624,11 +36590,11 @@ test_xmlStrncmp(void) { (len > xmlStrlen(BAD_CAST str2))) len = 0; - ret_val = xmlStrncmp((const xmlChar *)str1, (const xmlChar *)str2, len); + ret_val = xmlStrncmp(str1, str2, len); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str1, (const xmlChar *)str1, 0); - des_const_xmlChar_ptr(n_str2, (const xmlChar *)str2, 1); + des_const_xmlChar_ptr(n_str1, str1, 0); + des_const_xmlChar_ptr(n_str2, str2, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36655,7 +36621,7 @@ test_xmlStrndup(void) { int mem_base; xmlChar * ret_val; - xmlChar * cur; /* the input xmlChar * */ + const xmlChar * cur; /* the input xmlChar * */ int n_cur; int len; /* the len of @cur */ int n_len; @@ -36669,10 +36635,10 @@ test_xmlStrndup(void) { (len > xmlStrlen(BAD_CAST cur))) len = 0; - ret_val = xmlStrndup((const xmlChar *)cur, len); + ret_val = xmlStrndup(cur, len); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, (const xmlChar *)cur, 0); + des_const_xmlChar_ptr(n_cur, cur, 0); des_int(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36697,9 +36663,9 @@ test_xmlStrstr(void) { int mem_base; const xmlChar * ret_val; - xmlChar * str; /* the xmlChar * array (haystack) */ + const xmlChar * str; /* the xmlChar * array (haystack) */ int n_str; - xmlChar * val; /* the xmlChar to search (needle) */ + const xmlChar * val; /* the xmlChar to search (needle) */ int n_val; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { @@ -36708,11 +36674,11 @@ test_xmlStrstr(void) { str = gen_const_xmlChar_ptr(n_str, 0); val = gen_const_xmlChar_ptr(n_val, 1); - ret_val = xmlStrstr((const xmlChar *)str, (const xmlChar *)val); + ret_val = xmlStrstr(str, val); desret_const_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); - des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 1); + des_const_xmlChar_ptr(n_str, str, 0); + des_const_xmlChar_ptr(n_val, val, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlStrstr", @@ -36736,7 +36702,7 @@ test_xmlStrsub(void) { int mem_base; xmlChar * ret_val; - xmlChar * str; /* the xmlChar * array (haystack) */ + const xmlChar * str; /* the xmlChar * array (haystack) */ int n_str; int start; /* the index of the first char (zero based) */ int n_start; @@ -36757,10 +36723,10 @@ test_xmlStrsub(void) { (len > xmlStrlen(BAD_CAST str))) len = 0; - ret_val = xmlStrsub((const xmlChar *)str, start, len); + ret_val = xmlStrsub(str, start, len); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); des_int(n_start, start, 1); des_int(n_len, len, 2); xmlResetLastError(); @@ -36788,9 +36754,9 @@ test_xmlUTF8Charcmp(void) { int mem_base; int ret_val; - xmlChar * utf1; /* pointer to first UTF8 char */ + const xmlChar * utf1; /* pointer to first UTF8 char */ int n_utf1; - xmlChar * utf2; /* pointer to second UTF8 char */ + const xmlChar * utf2; /* pointer to second UTF8 char */ int n_utf2; for (n_utf1 = 0;n_utf1 < gen_nb_const_xmlChar_ptr;n_utf1++) { @@ -36799,11 +36765,11 @@ test_xmlUTF8Charcmp(void) { utf1 = gen_const_xmlChar_ptr(n_utf1, 0); utf2 = gen_const_xmlChar_ptr(n_utf2, 1); - ret_val = xmlUTF8Charcmp((const xmlChar *)utf1, (const xmlChar *)utf2); + ret_val = xmlUTF8Charcmp(utf1, utf2); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf1, (const xmlChar *)utf1, 0); - des_const_xmlChar_ptr(n_utf2, (const xmlChar *)utf2, 1); + des_const_xmlChar_ptr(n_utf1, utf1, 0); + des_const_xmlChar_ptr(n_utf2, utf2, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUTF8Charcmp", @@ -36827,17 +36793,17 @@ test_xmlUTF8Size(void) { int mem_base; int ret_val; - xmlChar * utf; /* pointer to the UTF8 character */ + const xmlChar * utf; /* pointer to the UTF8 character */ int n_utf; for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { mem_base = xmlMemBlocks(); utf = gen_const_xmlChar_ptr(n_utf, 0); - ret_val = xmlUTF8Size((const xmlChar *)utf); + ret_val = xmlUTF8Size(utf); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_const_xmlChar_ptr(n_utf, utf, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUTF8Size", @@ -36859,17 +36825,17 @@ test_xmlUTF8Strlen(void) { int mem_base; int ret_val; - xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ + const xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ int n_utf; for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { mem_base = xmlMemBlocks(); utf = gen_const_xmlChar_ptr(n_utf, 0); - ret_val = xmlUTF8Strlen((const xmlChar *)utf); + ret_val = xmlUTF8Strlen(utf); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_const_xmlChar_ptr(n_utf, utf, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUTF8Strlen", @@ -36891,9 +36857,9 @@ test_xmlUTF8Strloc(void) { int mem_base; int ret_val; - xmlChar * utf; /* the input UTF8 * */ + const xmlChar * utf; /* the input UTF8 * */ int n_utf; - xmlChar * utfchar; /* the UTF8 character to be found */ + const xmlChar * utfchar; /* the UTF8 character to be found */ int n_utfchar; for (n_utf = 0;n_utf < gen_nb_const_xmlChar_ptr;n_utf++) { @@ -36902,11 +36868,11 @@ test_xmlUTF8Strloc(void) { utf = gen_const_xmlChar_ptr(n_utf, 0); utfchar = gen_const_xmlChar_ptr(n_utfchar, 1); - ret_val = xmlUTF8Strloc((const xmlChar *)utf, (const xmlChar *)utfchar); + ret_val = xmlUTF8Strloc(utf, utfchar); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); - des_const_xmlChar_ptr(n_utfchar, (const xmlChar *)utfchar, 1); + des_const_xmlChar_ptr(n_utf, utf, 0); + des_const_xmlChar_ptr(n_utfchar, utfchar, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUTF8Strloc", @@ -36930,7 +36896,7 @@ test_xmlUTF8Strndup(void) { int mem_base; xmlChar * ret_val; - xmlChar * utf; /* the input UTF8 * */ + const xmlChar * utf; /* the input UTF8 * */ int n_utf; int len; /* the len of @utf (in chars) */ int n_len; @@ -36944,10 +36910,10 @@ test_xmlUTF8Strndup(void) { (len > xmlStrlen(BAD_CAST utf))) len = 0; - ret_val = xmlUTF8Strndup((const xmlChar *)utf, len); + ret_val = xmlUTF8Strndup(utf, len); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_const_xmlChar_ptr(n_utf, utf, 0); des_int(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -36972,7 +36938,7 @@ test_xmlUTF8Strpos(void) { int mem_base; const xmlChar * ret_val; - xmlChar * utf; /* the input UTF8 * */ + const xmlChar * utf; /* the input UTF8 * */ int n_utf; int pos; /* the position of the desired UTF8 char (in chars) */ int n_pos; @@ -36983,10 +36949,10 @@ test_xmlUTF8Strpos(void) { utf = gen_const_xmlChar_ptr(n_utf, 0); pos = gen_int(n_pos, 1); - ret_val = xmlUTF8Strpos((const xmlChar *)utf, pos); + ret_val = xmlUTF8Strpos(utf, pos); desret_const_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_const_xmlChar_ptr(n_utf, utf, 0); des_int(n_pos, pos, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -37011,7 +36977,7 @@ test_xmlUTF8Strsize(void) { int mem_base; int ret_val; - xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ + const xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ int n_utf; int len; /* the number of characters in the array */ int n_len; @@ -37025,10 +36991,10 @@ test_xmlUTF8Strsize(void) { (len > xmlStrlen(BAD_CAST utf))) len = 0; - ret_val = xmlUTF8Strsize((const xmlChar *)utf, len); + ret_val = xmlUTF8Strsize(utf, len); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_const_xmlChar_ptr(n_utf, utf, 0); des_int(n_len, len, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -37053,7 +37019,7 @@ test_xmlUTF8Strsub(void) { int mem_base; xmlChar * ret_val; - xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ + const xmlChar * utf; /* a sequence of UTF-8 encoded bytes */ int n_utf; int start; /* relative pos of first char */ int n_start; @@ -37074,10 +37040,10 @@ test_xmlUTF8Strsub(void) { (len > xmlStrlen(BAD_CAST utf))) len = 0; - ret_val = xmlUTF8Strsub((const xmlChar *)utf, start, len); + ret_val = xmlUTF8Strsub(utf, start, len); desret_xmlChar_ptr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_utf, (const xmlChar *)utf, 0); + des_const_xmlChar_ptr(n_utf, utf, 0); des_int(n_start, start, 1); des_int(n_len, len, 2); xmlResetLastError(); @@ -37452,7 +37418,7 @@ test_xmlUCSIsBlock(void) { int ret_val; int code; /* UCS code point */ int n_code; - char * block; /* UCS block name */ + const char * block; /* UCS block name */ int n_block; for (n_code = 0;n_code < gen_nb_int;n_code++) { @@ -37461,11 +37427,11 @@ test_xmlUCSIsBlock(void) { code = gen_int(n_code, 0); block = gen_const_char_ptr(n_block, 1); - ret_val = xmlUCSIsBlock(code, (const char *)block); + ret_val = xmlUCSIsBlock(code, block); desret_int(ret_val); call_tests++; des_int(n_code, code, 0); - des_const_char_ptr(n_block, (const char *)block, 1); + des_const_char_ptr(n_block, block, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUCSIsBlock", @@ -38037,7 +38003,7 @@ test_xmlUCSIsCat(void) { int ret_val; int code; /* UCS code point */ int n_code; - char * cat; /* UCS Category name */ + const char * cat; /* UCS Category name */ int n_cat; for (n_code = 0;n_code < gen_nb_int;n_code++) { @@ -38046,11 +38012,11 @@ test_xmlUCSIsCat(void) { code = gen_int(n_code, 0); cat = gen_const_char_ptr(n_cat, 1); - ret_val = xmlUCSIsCat(code, (const char *)cat); + ret_val = xmlUCSIsCat(code, cat); desret_int(ret_val); call_tests++; des_int(n_code, code, 0); - des_const_char_ptr(n_cat, (const char *)cat, 1); + des_const_char_ptr(n_cat, cat, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlUCSIsCat", @@ -43636,7 +43602,7 @@ test_xmlTextWriterSetIndentString(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * str; /* the xmlChar string */ + const xmlChar * str; /* the xmlChar string */ int n_str; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -43645,11 +43611,11 @@ test_xmlTextWriterSetIndentString(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); str = gen_const_xmlChar_ptr(n_str, 1); - ret_val = xmlTextWriterSetIndentString(writer, (const xmlChar *)str); + ret_val = xmlTextWriterSetIndentString(writer, str); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterSetIndentString", @@ -43718,7 +43684,7 @@ test_xmlTextWriterStartAttribute(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* element name */ + const xmlChar * name; /* element name */ int n_name; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -43727,11 +43693,11 @@ test_xmlTextWriterStartAttribute(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlTextWriterStartAttribute(writer, (const xmlChar *)name); + ret_val = xmlTextWriterStartAttribute(writer, name); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartAttribute", @@ -43759,11 +43725,11 @@ test_xmlTextWriterStartAttributeNS(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * prefix; /* namespace prefix or NULL */ + const xmlChar * prefix; /* namespace prefix or NULL */ int n_prefix; - xmlChar * name; /* element local name */ + const xmlChar * name; /* element local name */ int n_name; - xmlChar * namespaceURI; /* namespace URI or NULL */ + const xmlChar * namespaceURI; /* namespace URI or NULL */ int n_namespaceURI; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -43776,13 +43742,13 @@ test_xmlTextWriterStartAttributeNS(void) { name = gen_const_xmlChar_ptr(n_name, 2); namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); - ret_val = xmlTextWriterStartAttributeNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI); + ret_val = xmlTextWriterStartAttributeNS(writer, prefix, name, namespaceURI); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_namespaceURI, namespaceURI, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartAttributeNS", @@ -43882,11 +43848,11 @@ test_xmlTextWriterStartDTD(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* the name of the DTD */ + const xmlChar * name; /* the name of the DTD */ int n_name; - xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + const xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ int n_pubid; - xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + const xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ int n_sysid; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -43899,13 +43865,13 @@ test_xmlTextWriterStartDTD(void) { pubid = gen_const_xmlChar_ptr(n_pubid, 2); sysid = gen_const_xmlChar_ptr(n_sysid, 3); - ret_val = xmlTextWriterStartDTD(writer, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid); + ret_val = xmlTextWriterStartDTD(writer, name, pubid, sysid); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 2); - des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 3); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_pubid, pubid, 2); + des_const_xmlChar_ptr(n_sysid, sysid, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartDTD", @@ -43937,7 +43903,7 @@ test_xmlTextWriterStartDTDAttlist(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* the name of the DTD ATTLIST */ + const xmlChar * name; /* the name of the DTD ATTLIST */ int n_name; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -43946,11 +43912,11 @@ test_xmlTextWriterStartDTDAttlist(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlTextWriterStartDTDAttlist(writer, (const xmlChar *)name); + ret_val = xmlTextWriterStartDTDAttlist(writer, name); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartDTDAttlist", @@ -43978,7 +43944,7 @@ test_xmlTextWriterStartDTDElement(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* the name of the DTD element */ + const xmlChar * name; /* the name of the DTD element */ int n_name; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -43987,11 +43953,11 @@ test_xmlTextWriterStartDTDElement(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlTextWriterStartDTDElement(writer, (const xmlChar *)name); + ret_val = xmlTextWriterStartDTDElement(writer, name); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartDTDElement", @@ -44021,7 +43987,7 @@ test_xmlTextWriterStartDTDEntity(void) { int n_writer; int pe; /* TRUE if this is a parameter entity, FALSE if not */ int n_pe; - xmlChar * name; /* the name of the DTD ATTLIST */ + const xmlChar * name; /* the name of the DTD ATTLIST */ int n_name; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44032,12 +43998,12 @@ test_xmlTextWriterStartDTDEntity(void) { pe = gen_int(n_pe, 1); name = gen_const_xmlChar_ptr(n_name, 2); - ret_val = xmlTextWriterStartDTDEntity(writer, pe, (const xmlChar *)name); + ret_val = xmlTextWriterStartDTDEntity(writer, pe, name); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); des_int(n_pe, pe, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); + des_const_xmlChar_ptr(n_name, name, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartDTDEntity", @@ -44067,11 +44033,11 @@ test_xmlTextWriterStartDocument(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - char * version; /* the xml version ("1.0") or NULL for default ("1.0") */ + const char * version; /* the xml version ("1.0") or NULL for default ("1.0") */ int n_version; - char * encoding; /* the encoding or NULL for default */ + const char * encoding; /* the encoding or NULL for default */ int n_encoding; - char * standalone; /* "yes" or "no" or NULL for default */ + const char * standalone; /* "yes" or "no" or NULL for default */ int n_standalone; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44084,13 +44050,13 @@ test_xmlTextWriterStartDocument(void) { encoding = gen_const_char_ptr(n_encoding, 2); standalone = gen_const_char_ptr(n_standalone, 3); - ret_val = xmlTextWriterStartDocument(writer, (const char *)version, (const char *)encoding, (const char *)standalone); + ret_val = xmlTextWriterStartDocument(writer, version, encoding, standalone); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_char_ptr(n_version, (const char *)version, 1); - des_const_char_ptr(n_encoding, (const char *)encoding, 2); - des_const_char_ptr(n_standalone, (const char *)standalone, 3); + des_const_char_ptr(n_version, version, 1); + des_const_char_ptr(n_encoding, encoding, 2); + des_const_char_ptr(n_standalone, standalone, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartDocument", @@ -44122,7 +44088,7 @@ test_xmlTextWriterStartElement(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* element name */ + const xmlChar * name; /* element name */ int n_name; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44131,11 +44097,11 @@ test_xmlTextWriterStartElement(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlTextWriterStartElement(writer, (const xmlChar *)name); + ret_val = xmlTextWriterStartElement(writer, name); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartElement", @@ -44163,11 +44129,11 @@ test_xmlTextWriterStartElementNS(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * prefix; /* namespace prefix or NULL */ + const xmlChar * prefix; /* namespace prefix or NULL */ int n_prefix; - xmlChar * name; /* element local name */ + const xmlChar * name; /* element local name */ int n_name; - xmlChar * namespaceURI; /* namespace URI or NULL */ + const xmlChar * namespaceURI; /* namespace URI or NULL */ int n_namespaceURI; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44180,13 +44146,13 @@ test_xmlTextWriterStartElementNS(void) { name = gen_const_xmlChar_ptr(n_name, 2); namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); - ret_val = xmlTextWriterStartElementNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI); + ret_val = xmlTextWriterStartElementNS(writer, prefix, name, namespaceURI); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_namespaceURI, namespaceURI, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartElementNS", @@ -44218,7 +44184,7 @@ test_xmlTextWriterStartPI(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * target; /* PI target */ + const xmlChar * target; /* PI target */ int n_target; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44227,11 +44193,11 @@ test_xmlTextWriterStartPI(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); target = gen_const_xmlChar_ptr(n_target, 1); - ret_val = xmlTextWriterStartPI(writer, (const xmlChar *)target); + ret_val = xmlTextWriterStartPI(writer, target); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_target, (const xmlChar *)target, 1); + des_const_xmlChar_ptr(n_target, target, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterStartPI", @@ -44259,9 +44225,9 @@ test_xmlTextWriterWriteAttribute(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* attribute name */ + const xmlChar * name; /* attribute name */ int n_name; - xmlChar * content; /* attribute content */ + const xmlChar * content; /* attribute content */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44272,12 +44238,12 @@ test_xmlTextWriterWriteAttribute(void) { name = gen_const_xmlChar_ptr(n_name, 1); content = gen_const_xmlChar_ptr(n_content, 2); - ret_val = xmlTextWriterWriteAttribute(writer, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlTextWriterWriteAttribute(writer, name, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_content, content, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteAttribute", @@ -44307,13 +44273,13 @@ test_xmlTextWriterWriteAttributeNS(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * prefix; /* namespace prefix */ + const xmlChar * prefix; /* namespace prefix */ int n_prefix; - xmlChar * name; /* attribute local name */ + const xmlChar * name; /* attribute local name */ int n_name; - xmlChar * namespaceURI; /* namespace URI */ + const xmlChar * namespaceURI; /* namespace URI */ int n_namespaceURI; - xmlChar * content; /* attribute content */ + const xmlChar * content; /* attribute content */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44328,14 +44294,14 @@ test_xmlTextWriterWriteAttributeNS(void) { namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); content = gen_const_xmlChar_ptr(n_content, 4); - ret_val = xmlTextWriterWriteAttributeNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI, (const xmlChar *)content); + ret_val = xmlTextWriterWriteAttributeNS(writer, prefix, name, namespaceURI, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 4); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_namespaceURI, namespaceURI, 3); + des_const_xmlChar_ptr(n_content, content, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteAttributeNS", @@ -44369,7 +44335,7 @@ test_xmlTextWriterWriteBase64(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - char * data; /* binary data */ + const char * data; /* binary data */ int n_data; int start; /* the position within the data of the first byte to encode */ int n_start; @@ -44392,11 +44358,11 @@ test_xmlTextWriterWriteBase64(void) { (len > xmlStrlen(BAD_CAST data))) len = 0; - ret_val = xmlTextWriterWriteBase64(writer, (const char *)data, start, len); + ret_val = xmlTextWriterWriteBase64(writer, data, start, len); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_char_ptr(n_data, (const char *)data, 1); + des_const_char_ptr(n_data, data, 1); des_int(n_start, start, 2); des_int(n_len, len, 3); xmlResetLastError(); @@ -44430,7 +44396,7 @@ test_xmlTextWriterWriteBinHex(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - char * data; /* binary data */ + const char * data; /* binary data */ int n_data; int start; /* the position within the data of the first byte to encode */ int n_start; @@ -44453,11 +44419,11 @@ test_xmlTextWriterWriteBinHex(void) { (len > xmlStrlen(BAD_CAST data))) len = 0; - ret_val = xmlTextWriterWriteBinHex(writer, (const char *)data, start, len); + ret_val = xmlTextWriterWriteBinHex(writer, data, start, len); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_char_ptr(n_data, (const char *)data, 1); + des_const_char_ptr(n_data, data, 1); des_int(n_start, start, 2); des_int(n_len, len, 3); xmlResetLastError(); @@ -44491,7 +44457,7 @@ test_xmlTextWriterWriteCDATA(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * content; /* CDATA content */ + const xmlChar * content; /* CDATA content */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44500,11 +44466,11 @@ test_xmlTextWriterWriteCDATA(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlTextWriterWriteCDATA(writer, (const xmlChar *)content); + ret_val = xmlTextWriterWriteCDATA(writer, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteCDATA", @@ -44532,7 +44498,7 @@ test_xmlTextWriterWriteComment(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * content; /* comment string */ + const xmlChar * content; /* comment string */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44541,11 +44507,11 @@ test_xmlTextWriterWriteComment(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlTextWriterWriteComment(writer, (const xmlChar *)content); + ret_val = xmlTextWriterWriteComment(writer, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteComment", @@ -44573,13 +44539,13 @@ test_xmlTextWriterWriteDTD(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* the name of the DTD */ + const xmlChar * name; /* the name of the DTD */ int n_name; - xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + const xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ int n_pubid; - xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + const xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ int n_sysid; - xmlChar * subset; /* string content of the DTD */ + const xmlChar * subset; /* string content of the DTD */ int n_subset; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44594,14 +44560,14 @@ test_xmlTextWriterWriteDTD(void) { sysid = gen_const_xmlChar_ptr(n_sysid, 3); subset = gen_const_xmlChar_ptr(n_subset, 4); - ret_val = xmlTextWriterWriteDTD(writer, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)subset); + ret_val = xmlTextWriterWriteDTD(writer, name, pubid, sysid, subset); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 2); - des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 3); - des_const_xmlChar_ptr(n_subset, (const xmlChar *)subset, 4); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_pubid, pubid, 2); + des_const_xmlChar_ptr(n_sysid, sysid, 3); + des_const_xmlChar_ptr(n_subset, subset, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTD", @@ -44635,9 +44601,9 @@ test_xmlTextWriterWriteDTDAttlist(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* the name of the DTD ATTLIST */ + const xmlChar * name; /* the name of the DTD ATTLIST */ int n_name; - xmlChar * content; /* content of the ATTLIST */ + const xmlChar * content; /* content of the ATTLIST */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44648,12 +44614,12 @@ test_xmlTextWriterWriteDTDAttlist(void) { name = gen_const_xmlChar_ptr(n_name, 1); content = gen_const_xmlChar_ptr(n_content, 2); - ret_val = xmlTextWriterWriteDTDAttlist(writer, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlTextWriterWriteDTDAttlist(writer, name, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_content, content, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTDAttlist", @@ -44683,9 +44649,9 @@ test_xmlTextWriterWriteDTDElement(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* the name of the DTD element */ + const xmlChar * name; /* the name of the DTD element */ int n_name; - xmlChar * content; /* content of the element */ + const xmlChar * content; /* content of the element */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44696,12 +44662,12 @@ test_xmlTextWriterWriteDTDElement(void) { name = gen_const_xmlChar_ptr(n_name, 1); content = gen_const_xmlChar_ptr(n_content, 2); - ret_val = xmlTextWriterWriteDTDElement(writer, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlTextWriterWriteDTDElement(writer, name, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_content, content, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTDElement", @@ -44733,15 +44699,15 @@ test_xmlTextWriterWriteDTDEntity(void) { int n_writer; int pe; /* TRUE if this is a parameter entity, FALSE if not */ int n_pe; - xmlChar * name; /* the name of the DTD entity */ + const xmlChar * name; /* the name of the DTD entity */ int n_name; - xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + const xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ int n_pubid; - xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + const xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ int n_sysid; - xmlChar * ndataid; /* the xml notation name. */ + const xmlChar * ndataid; /* the xml notation name. */ int n_ndataid; - xmlChar * content; /* content of the entity */ + const xmlChar * content; /* content of the entity */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44760,16 +44726,16 @@ test_xmlTextWriterWriteDTDEntity(void) { ndataid = gen_const_xmlChar_ptr(n_ndataid, 5); content = gen_const_xmlChar_ptr(n_content, 6); - ret_val = xmlTextWriterWriteDTDEntity(writer, pe, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)ndataid, (const xmlChar *)content); + ret_val = xmlTextWriterWriteDTDEntity(writer, pe, name, pubid, sysid, ndataid, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); des_int(n_pe, pe, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 3); - des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 4); - des_const_xmlChar_ptr(n_ndataid, (const xmlChar *)ndataid, 5); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 6); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_pubid, pubid, 3); + des_const_xmlChar_ptr(n_sysid, sysid, 4); + des_const_xmlChar_ptr(n_ndataid, ndataid, 5); + des_const_xmlChar_ptr(n_content, content, 6); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTDEntity", @@ -44809,13 +44775,13 @@ test_xmlTextWriterWriteDTDExternalEntity(void) { int n_writer; int pe; /* TRUE if this is a parameter entity, FALSE if not */ int n_pe; - xmlChar * name; /* the name of the DTD entity */ + const xmlChar * name; /* the name of the DTD entity */ int n_name; - xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + const xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ int n_pubid; - xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + const xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ int n_sysid; - xmlChar * ndataid; /* the xml notation name. */ + const xmlChar * ndataid; /* the xml notation name. */ int n_ndataid; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44832,15 +44798,15 @@ test_xmlTextWriterWriteDTDExternalEntity(void) { sysid = gen_const_xmlChar_ptr(n_sysid, 4); ndataid = gen_const_xmlChar_ptr(n_ndataid, 5); - ret_val = xmlTextWriterWriteDTDExternalEntity(writer, pe, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)ndataid); + ret_val = xmlTextWriterWriteDTDExternalEntity(writer, pe, name, pubid, sysid, ndataid); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); des_int(n_pe, pe, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 3); - des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 4); - des_const_xmlChar_ptr(n_ndataid, (const xmlChar *)ndataid, 5); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_pubid, pubid, 3); + des_const_xmlChar_ptr(n_sysid, sysid, 4); + des_const_xmlChar_ptr(n_ndataid, ndataid, 5); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTDExternalEntity", @@ -44876,11 +44842,11 @@ test_xmlTextWriterWriteDTDExternalEntityContents(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + const xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ int n_pubid; - xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + const xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ int n_sysid; - xmlChar * ndataid; /* the xml notation name. */ + const xmlChar * ndataid; /* the xml notation name. */ int n_ndataid; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44893,13 +44859,13 @@ test_xmlTextWriterWriteDTDExternalEntityContents(void) { sysid = gen_const_xmlChar_ptr(n_sysid, 2); ndataid = gen_const_xmlChar_ptr(n_ndataid, 3); - ret_val = xmlTextWriterWriteDTDExternalEntityContents(writer, (const xmlChar *)pubid, (const xmlChar *)sysid, (const xmlChar *)ndataid); + ret_val = xmlTextWriterWriteDTDExternalEntityContents(writer, pubid, sysid, ndataid); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 1); - des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 2); - des_const_xmlChar_ptr(n_ndataid, (const xmlChar *)ndataid, 3); + des_const_xmlChar_ptr(n_pubid, pubid, 1); + des_const_xmlChar_ptr(n_sysid, sysid, 2); + des_const_xmlChar_ptr(n_ndataid, ndataid, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTDExternalEntityContents", @@ -44933,9 +44899,9 @@ test_xmlTextWriterWriteDTDInternalEntity(void) { int n_writer; int pe; /* TRUE if this is a parameter entity, FALSE if not */ int n_pe; - xmlChar * name; /* the name of the DTD entity */ + const xmlChar * name; /* the name of the DTD entity */ int n_name; - xmlChar * content; /* content of the entity */ + const xmlChar * content; /* content of the entity */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -44948,13 +44914,13 @@ test_xmlTextWriterWriteDTDInternalEntity(void) { name = gen_const_xmlChar_ptr(n_name, 2); content = gen_const_xmlChar_ptr(n_content, 3); - ret_val = xmlTextWriterWriteDTDInternalEntity(writer, pe, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlTextWriterWriteDTDInternalEntity(writer, pe, name, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); des_int(n_pe, pe, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 3); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_content, content, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTDInternalEntity", @@ -44986,11 +44952,11 @@ test_xmlTextWriterWriteDTDNotation(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* the name of the xml notation */ + const xmlChar * name; /* the name of the xml notation */ int n_name; - xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ + const xmlChar * pubid; /* the public identifier, which is an alternative to the system identifier */ int n_pubid; - xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ + const xmlChar * sysid; /* the system identifier, which is the URI of the DTD */ int n_sysid; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -45003,13 +44969,13 @@ test_xmlTextWriterWriteDTDNotation(void) { pubid = gen_const_xmlChar_ptr(n_pubid, 2); sysid = gen_const_xmlChar_ptr(n_sysid, 3); - ret_val = xmlTextWriterWriteDTDNotation(writer, (const xmlChar *)name, (const xmlChar *)pubid, (const xmlChar *)sysid); + ret_val = xmlTextWriterWriteDTDNotation(writer, name, pubid, sysid); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_pubid, (const xmlChar *)pubid, 2); - des_const_xmlChar_ptr(n_sysid, (const xmlChar *)sysid, 3); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_pubid, pubid, 2); + des_const_xmlChar_ptr(n_sysid, sysid, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteDTDNotation", @@ -45041,9 +45007,9 @@ test_xmlTextWriterWriteElement(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * name; /* element name */ + const xmlChar * name; /* element name */ int n_name; - xmlChar * content; /* element content */ + const xmlChar * content; /* element content */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -45054,12 +45020,12 @@ test_xmlTextWriterWriteElement(void) { name = gen_const_xmlChar_ptr(n_name, 1); content = gen_const_xmlChar_ptr(n_content, 2); - ret_val = xmlTextWriterWriteElement(writer, (const xmlChar *)name, (const xmlChar *)content); + ret_val = xmlTextWriterWriteElement(writer, name, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_content, content, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteElement", @@ -45089,13 +45055,13 @@ test_xmlTextWriterWriteElementNS(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * prefix; /* namespace prefix */ + const xmlChar * prefix; /* namespace prefix */ int n_prefix; - xmlChar * name; /* element local name */ + const xmlChar * name; /* element local name */ int n_name; - xmlChar * namespaceURI; /* namespace URI */ + const xmlChar * namespaceURI; /* namespace URI */ int n_namespaceURI; - xmlChar * content; /* element content */ + const xmlChar * content; /* element content */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -45110,14 +45076,14 @@ test_xmlTextWriterWriteElementNS(void) { namespaceURI = gen_const_xmlChar_ptr(n_namespaceURI, 3); content = gen_const_xmlChar_ptr(n_content, 4); - ret_val = xmlTextWriterWriteElementNS(writer, (const xmlChar *)prefix, (const xmlChar *)name, (const xmlChar *)namespaceURI, (const xmlChar *)content); + ret_val = xmlTextWriterWriteElementNS(writer, prefix, name, namespaceURI, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 2); - des_const_xmlChar_ptr(n_namespaceURI, (const xmlChar *)namespaceURI, 3); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 4); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_const_xmlChar_ptr(n_namespaceURI, namespaceURI, 3); + des_const_xmlChar_ptr(n_content, content, 4); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteElementNS", @@ -45281,9 +45247,9 @@ test_xmlTextWriterWritePI(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * target; /* PI target */ + const xmlChar * target; /* PI target */ int n_target; - xmlChar * content; /* PI content */ + const xmlChar * content; /* PI content */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -45294,12 +45260,12 @@ test_xmlTextWriterWritePI(void) { target = gen_const_xmlChar_ptr(n_target, 1); content = gen_const_xmlChar_ptr(n_content, 2); - ret_val = xmlTextWriterWritePI(writer, (const xmlChar *)target, (const xmlChar *)content); + ret_val = xmlTextWriterWritePI(writer, target, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_target, (const xmlChar *)target, 1); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 2); + des_const_xmlChar_ptr(n_target, target, 1); + des_const_xmlChar_ptr(n_content, content, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWritePI", @@ -45329,7 +45295,7 @@ test_xmlTextWriterWriteRaw(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * content; /* text string */ + const xmlChar * content; /* text string */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -45338,11 +45304,11 @@ test_xmlTextWriterWriteRaw(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlTextWriterWriteRaw(writer, (const xmlChar *)content); + ret_val = xmlTextWriterWriteRaw(writer, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteRaw", @@ -45370,7 +45336,7 @@ test_xmlTextWriterWriteRawLen(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * content; /* text string */ + const xmlChar * content; /* text string */ int n_content; int len; /* length of the text string */ int n_len; @@ -45386,11 +45352,11 @@ test_xmlTextWriterWriteRawLen(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - ret_val = xmlTextWriterWriteRawLen(writer, (const xmlChar *)content, len); + ret_val = xmlTextWriterWriteRawLen(writer, content, len); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); des_int(n_len, len, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -45421,7 +45387,7 @@ test_xmlTextWriterWriteString(void) { int ret_val; xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ int n_writer; - xmlChar * content; /* text string */ + const xmlChar * content; /* text string */ int n_content; for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { @@ -45430,11 +45396,11 @@ test_xmlTextWriterWriteString(void) { writer = gen_xmlTextWriterPtr(n_writer, 0); content = gen_const_xmlChar_ptr(n_content, 1); - ret_val = xmlTextWriterWriteString(writer, (const xmlChar *)content); + ret_val = xmlTextWriterWriteString(writer, content); desret_int(ret_val); call_tests++; des_xmlTextWriterPtr(n_writer, writer, 0); - des_const_xmlChar_ptr(n_content, (const xmlChar *)content, 1); + des_const_xmlChar_ptr(n_content, content, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlTextWriterWriteString", @@ -45984,17 +45950,17 @@ test_xmlXPathCastStringToBoolean(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; int ret_val; - xmlChar * val; /* a string */ + const xmlChar * val; /* a string */ int n_val; for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { mem_base = xmlMemBlocks(); val = gen_const_xmlChar_ptr(n_val, 0); - ret_val = xmlXPathCastStringToBoolean((const xmlChar *)val); + ret_val = xmlXPathCastStringToBoolean(val); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 0); + des_const_xmlChar_ptr(n_val, val, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathCastStringToBoolean", @@ -46018,17 +45984,17 @@ test_xmlXPathCastStringToNumber(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; double ret_val; - xmlChar * val; /* a string */ + const xmlChar * val; /* a string */ int n_val; for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { mem_base = xmlMemBlocks(); val = gen_const_xmlChar_ptr(n_val, 0); - ret_val = xmlXPathCastStringToNumber((const xmlChar *)val); + ret_val = xmlXPathCastStringToNumber(val); desret_double(ret_val); call_tests++; - des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 0); + des_const_xmlChar_ptr(n_val, val, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathCastStringToNumber", @@ -46471,7 +46437,7 @@ test_xmlXPathEval(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; xmlXPathObjectPtr ret_val; - xmlChar * str; /* the XPath expression */ + const xmlChar * str; /* the XPath expression */ int n_str; xmlXPathContextPtr ctx; /* the XPath context */ int n_ctx; @@ -46482,10 +46448,10 @@ test_xmlXPathEval(void) { str = gen_const_xmlChar_ptr(n_str, 0); ctx = gen_xmlXPathContextPtr(n_ctx, 1); - ret_val = xmlXPathEval((const xmlChar *)str, ctx); + ret_val = xmlXPathEval(str, ctx); desret_xmlXPathObjectPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); des_xmlXPathContextPtr(n_ctx, ctx, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -46512,7 +46478,7 @@ test_xmlXPathEvalExpression(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; xmlXPathObjectPtr ret_val; - xmlChar * str; /* the XPath expression */ + const xmlChar * str; /* the XPath expression */ int n_str; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; @@ -46523,10 +46489,10 @@ test_xmlXPathEvalExpression(void) { str = gen_const_xmlChar_ptr(n_str, 0); ctxt = gen_xmlXPathContextPtr(n_ctxt, 1); - ret_val = xmlXPathEvalExpression((const xmlChar *)str, ctxt); + ret_val = xmlXPathEvalExpression(str, ctxt); desret_xmlXPathObjectPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); des_xmlXPathContextPtr(n_ctxt, ctxt, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -46699,7 +46665,7 @@ test_xmlXPathNodeEval(void) { xmlXPathObjectPtr ret_val; xmlNodePtr node; /* the node to to use as the context node */ int n_node; - xmlChar * str; /* the XPath expression */ + const xmlChar * str; /* the XPath expression */ int n_str; xmlXPathContextPtr ctx; /* the XPath context */ int n_ctx; @@ -46712,11 +46678,11 @@ test_xmlXPathNodeEval(void) { str = gen_const_xmlChar_ptr(n_str, 1); ctx = gen_xmlXPathContextPtr(n_ctx, 2); - ret_val = xmlXPathNodeEval(node, (const xmlChar *)str, ctx); + ret_val = xmlXPathNodeEval(node, str, ctx); desret_xmlXPathObjectPtr(ret_val); call_tests++; des_xmlNodePtr(n_node, node, 0); - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 1); + des_const_xmlChar_ptr(n_str, str, 1); des_xmlXPathContextPtr(n_ctx, ctx, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -47888,17 +47854,17 @@ test_xmlXPathIsNodeType(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; int ret_val; - xmlChar * name; /* a name string */ + const xmlChar * name; /* a name string */ int n_name; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { mem_base = xmlMemBlocks(); name = gen_const_xmlChar_ptr(n_name, 0); - ret_val = xmlXPathIsNodeType((const xmlChar *)name); + ret_val = xmlXPathIsNodeType(name); desret_int(ret_val); call_tests++; - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 0); + des_const_xmlChar_ptr(n_name, name, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathIsNodeType", @@ -48258,17 +48224,17 @@ test_xmlXPathNewCString(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; xmlXPathObjectPtr ret_val; - char * val; /* the char * value */ + const char * val; /* the char * value */ int n_val; for (n_val = 0;n_val < gen_nb_const_char_ptr;n_val++) { mem_base = xmlMemBlocks(); val = gen_const_char_ptr(n_val, 0); - ret_val = xmlXPathNewCString((const char *)val); + ret_val = xmlXPathNewCString(val); desret_xmlXPathObjectPtr(ret_val); call_tests++; - des_const_char_ptr(n_val, (const char *)val, 0); + des_const_char_ptr(n_val, val, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathNewCString", @@ -48404,17 +48370,17 @@ test_xmlXPathNewString(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; xmlXPathObjectPtr ret_val; - xmlChar * val; /* the xmlChar * value */ + const xmlChar * val; /* the xmlChar * value */ int n_val; for (n_val = 0;n_val < gen_nb_const_xmlChar_ptr;n_val++) { mem_base = xmlMemBlocks(); val = gen_const_xmlChar_ptr(n_val, 0); - ret_val = xmlXPathNewString((const xmlChar *)val); + ret_val = xmlXPathNewString(val); desret_xmlXPathObjectPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_val, (const xmlChar *)val, 0); + des_const_xmlChar_ptr(n_val, val, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathNewString", @@ -49571,7 +49537,7 @@ test_xmlXPathNsLookup(void) { const xmlChar * ret_val; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; - xmlChar * prefix; /* the namespace prefix value */ + const xmlChar * prefix; /* the namespace prefix value */ int n_prefix; for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { @@ -49580,11 +49546,11 @@ test_xmlXPathNsLookup(void) { ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); prefix = gen_const_xmlChar_ptr(n_prefix, 1); - ret_val = xmlXPathNsLookup(ctxt, (const xmlChar *)prefix); + ret_val = xmlXPathNsLookup(ctxt, prefix); desret_const_xmlChar_ptr(ret_val); call_tests++; des_xmlXPathContextPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); + des_const_xmlChar_ptr(n_prefix, prefix, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathNsLookup", @@ -49990,9 +49956,9 @@ test_xmlXPathRegisterNs(void) { int ret_val; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; - xmlChar * prefix; /* the namespace prefix cannot be NULL or empty string */ + const xmlChar * prefix; /* the namespace prefix cannot be NULL or empty string */ int n_prefix; - xmlChar * ns_uri; /* the namespace name */ + const xmlChar * ns_uri; /* the namespace name */ int n_ns_uri; for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { @@ -50003,12 +49969,12 @@ test_xmlXPathRegisterNs(void) { prefix = gen_const_xmlChar_ptr(n_prefix, 1); ns_uri = gen_const_xmlChar_ptr(n_ns_uri, 2); - ret_val = xmlXPathRegisterNs(ctxt, (const xmlChar *)prefix, (const xmlChar *)ns_uri); + ret_val = xmlXPathRegisterNs(ctxt, prefix, ns_uri); desret_int(ret_val); call_tests++; des_xmlXPathContextPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_prefix, (const xmlChar *)prefix, 1); - des_const_xmlChar_ptr(n_ns_uri, (const xmlChar *)ns_uri, 2); + des_const_xmlChar_ptr(n_prefix, prefix, 1); + des_const_xmlChar_ptr(n_ns_uri, ns_uri, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathRegisterNs", @@ -50038,7 +50004,7 @@ test_xmlXPathRegisterVariable(void) { int ret_val; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; - xmlChar * name; /* the variable name */ + const xmlChar * name; /* the variable name */ int n_name; xmlXPathObjectPtr value; /* the variable value or NULL */ int n_value; @@ -50051,11 +50017,11 @@ test_xmlXPathRegisterVariable(void) { name = gen_const_xmlChar_ptr(n_name, 1); value = gen_xmlXPathObjectPtr(n_value, 2); - ret_val = xmlXPathRegisterVariable(ctxt, (const xmlChar *)name, value); + ret_val = xmlXPathRegisterVariable(ctxt, name, value); desret_int(ret_val); call_tests++; des_xmlXPathContextPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); des_xmlXPathObjectPtr(n_value, value, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -50096,9 +50062,9 @@ test_xmlXPathRegisterVariableNS(void) { int ret_val; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; - xmlChar * name; /* the variable name */ + const xmlChar * name; /* the variable name */ int n_name; - xmlChar * ns_uri; /* the variable namespace URI */ + const xmlChar * ns_uri; /* the variable namespace URI */ int n_ns_uri; xmlXPathObjectPtr value; /* the variable value or NULL */ int n_value; @@ -50113,12 +50079,12 @@ test_xmlXPathRegisterVariableNS(void) { ns_uri = gen_const_xmlChar_ptr(n_ns_uri, 2); value = gen_xmlXPathObjectPtr(n_value, 3); - ret_val = xmlXPathRegisterVariableNS(ctxt, (const xmlChar *)name, (const xmlChar *)ns_uri, value); + ret_val = xmlXPathRegisterVariableNS(ctxt, name, ns_uri, value); desret_int(ret_val); call_tests++; des_xmlXPathContextPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ns_uri, (const xmlChar *)ns_uri, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ns_uri, ns_uri, 2); des_xmlXPathObjectPtr(n_value, value, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -50355,17 +50321,17 @@ test_xmlXPathStringEvalNumber(void) { #if defined(LIBXML_XPATH_ENABLED) int mem_base; double ret_val; - xmlChar * str; /* A string to scan */ + const xmlChar * str; /* A string to scan */ int n_str; for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { mem_base = xmlMemBlocks(); str = gen_const_xmlChar_ptr(n_str, 0); - ret_val = xmlXPathStringEvalNumber((const xmlChar *)str); + ret_val = xmlXPathStringEvalNumber(str); desret_double(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathStringEvalNumber", @@ -50849,7 +50815,7 @@ test_xmlXPathVariableLookup(void) { xmlXPathObjectPtr ret_val; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; - xmlChar * name; /* the variable name */ + const xmlChar * name; /* the variable name */ int n_name; for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { @@ -50858,11 +50824,11 @@ test_xmlXPathVariableLookup(void) { ctxt = gen_xmlXPathContextPtr(n_ctxt, 0); name = gen_const_xmlChar_ptr(n_name, 1); - ret_val = xmlXPathVariableLookup(ctxt, (const xmlChar *)name); + ret_val = xmlXPathVariableLookup(ctxt, name); desret_xmlXPathObjectPtr(ret_val); call_tests++; des_xmlXPathContextPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); + des_const_xmlChar_ptr(n_name, name, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathVariableLookup", @@ -50890,9 +50856,9 @@ test_xmlXPathVariableLookupNS(void) { xmlXPathObjectPtr ret_val; xmlXPathContextPtr ctxt; /* the XPath context */ int n_ctxt; - xmlChar * name; /* the variable name */ + const xmlChar * name; /* the variable name */ int n_name; - xmlChar * ns_uri; /* the variable namespace URI */ + const xmlChar * ns_uri; /* the variable namespace URI */ int n_ns_uri; for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathContextPtr;n_ctxt++) { @@ -50903,12 +50869,12 @@ test_xmlXPathVariableLookupNS(void) { name = gen_const_xmlChar_ptr(n_name, 1); ns_uri = gen_const_xmlChar_ptr(n_ns_uri, 2); - ret_val = xmlXPathVariableLookupNS(ctxt, (const xmlChar *)name, (const xmlChar *)ns_uri); + ret_val = xmlXPathVariableLookupNS(ctxt, name, ns_uri); desret_xmlXPathObjectPtr(ret_val); call_tests++; des_xmlXPathContextPtr(n_ctxt, ctxt, 0); - des_const_xmlChar_ptr(n_name, (const xmlChar *)name, 1); - des_const_xmlChar_ptr(n_ns_uri, (const xmlChar *)ns_uri, 2); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_ns_uri, ns_uri, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathVariableLookupNS", @@ -51248,7 +51214,7 @@ test_xmlXPtrEval(void) { #if defined(LIBXML_XPTR_ENABLED) int mem_base; xmlXPathObjectPtr ret_val; - xmlChar * str; /* the XPointer expression */ + const xmlChar * str; /* the XPointer expression */ int n_str; xmlXPathContextPtr ctx; /* the XPointer context */ int n_ctx; @@ -51259,10 +51225,10 @@ test_xmlXPtrEval(void) { str = gen_const_xmlChar_ptr(n_str, 0); ctx = gen_xmlXPathContextPtr(n_ctx, 1); - ret_val = xmlXPtrEval((const xmlChar *)str, ctx); + ret_val = xmlXPtrEval(str, ctx); desret_xmlXPathObjectPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_str, (const xmlChar *)str, 0); + des_const_xmlChar_ptr(n_str, str, 0); des_xmlXPathContextPtr(n_ctx, ctx, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { From 7d6969d95509a94347d6f96167ac5420abafa291 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 23 Nov 2023 15:48:52 +0100 Subject: [PATCH 019/504] Remove Trio Trio is a rather old cross-platform printf library which was bundled with libxml2. It was needed for ancient pre-C99 systems without snprintf and should be safe to remove these days. --- CMakeLists.txt | 7 +- Copyright | 6 +- Makefile.am | 6 +- configure.ac | 15 - doc/apibuild.py | 4 - include/libxml/xmlversion.h.in | 25 - libxml.h | 5 - python/libxml.c | 5 - trio.c | 6892 -------------------------------- trio.h | 230 -- triodef.h | 228 -- trionan.c | 914 ----- trionan.h | 84 - triop.h | 150 - triostr.c | 2112 ---------- triostr.h | 144 - win32/configure.js | 10 +- 17 files changed, 6 insertions(+), 10831 deletions(-) delete mode 100644 trio.c delete mode 100644 trio.h delete mode 100644 triodef.h delete mode 100644 trionan.c delete mode 100644 trionan.h delete mode 100644 triop.h delete mode 100644 triostr.c delete mode 100644 triostr.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6553255c1..c7c9eeb94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,6 @@ option(LIBXML2_WITH_TESTS "Build tests" ON) option(LIBXML2_WITH_THREADS "Add multithread support" ON) option(LIBXML2_WITH_THREAD_ALLOC "Add per-thread memory" OFF) option(LIBXML2_WITH_TREE "Add the DOM like tree manipulation APIs" ON) -set(LIBXML2_WITH_TRIO OFF) set(LIBXML2_WITH_UNICODE ON) option(LIBXML2_WITH_VALID "Add the DTD validation support" ON) option(LIBXML2_WITH_WRITER "Add the xmlWriter saving interface" ON) @@ -73,7 +72,7 @@ if(LIBXML2_WITH_PYTHON) CACHE PATH "Python bindings install directory") endif() -foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB) +foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB) if(LIBXML2_${VARIABLE}) set(${VARIABLE} 1) else() @@ -330,10 +329,6 @@ if(WIN32) ) endif() -if(LIBXML2_WITH_TRIO) - list(APPEND LIBXML2_SRCS trio.c triostr.c) -endif() - add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS}) add_library(LibXml2::LibXml2 ALIAS LibXml2) diff --git a/Copyright b/Copyright index c058f0222..f76a86df6 100644 --- a/Copyright +++ b/Copyright @@ -1,6 +1,6 @@ -Except where otherwise noted in the source code (e.g. the files dict.c, -list.c and the trio files, which are covered by a similar licence but -with different Copyright notices) all the files are: +Except where otherwise noted in the source code (e.g. the files dict.c and +list.c, which are covered by a similar licence but with different Copyright +notices) all the files are: Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. diff --git a/Makefile.am b/Makefile.am index 0a49d3754..826ee8f00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,9 +97,6 @@ endif if WITH_SCHEMATRON_SOURCES libxml2_la_SOURCES += schematron.c endif -if WITH_TRIO_SOURCES -libxml2_la_SOURCES += triostr.c trio.c -endif if WITH_WRITER_SOURCES libxml2_la_SOURCES += xmlwriter.c endif @@ -389,8 +386,7 @@ EXTRA_DIST = Copyright check-xml-test-suite.py gentest.py \ check-xsddata-test-suite.py check-xinclude-test-suite.py \ example/Makefile.am example/gjobread.c example/gjobs.xml \ libxml2-config.cmake.in autogen.sh \ - trionan.c trionan.h triostr.c triostr.h trio.c trio.h \ - triop.h triodef.h libxml.h \ + libxml.h \ genUnicode.py \ dbgen.pl dbgenattr.pl \ libxml2.syms timsort.h \ diff --git a/configure.ac b/configure.ac index 0dd507207..630784752 100644 --- a/configure.ac +++ b/configure.ac @@ -530,9 +530,6 @@ case ${host} in *-*-solaris*) XML_LIBDIR="${XML_LIBDIR} -R${libdir}" ;; - hppa*-hp-mpeix) - NEED_TRIO=1 - ;; *-*-cygwin* | *-*-mingw* | *-*-msys* ) # If the host is Windows, and shared libraries are disabled, we # need to add -DLIBXML_STATIC to AM_CFLAGS in order for linking to @@ -839,18 +836,6 @@ AC_SUBST(MODULE_PLATFORM_LIBS) AC_SUBST(MODULE_EXTENSION) AM_CONDITIONAL(WITH_MODULES_SOURCES, test "$WITH_MODULES" = "1") -dnl -dnl Check for trio string functions -dnl -if test "${NEED_TRIO}" = "1" ; then - echo Adding trio library for string functions - WITH_TRIO=1 -else - WITH_TRIO=0 -fi -AM_CONDITIONAL(WITH_TRIO_SOURCES, test "${NEED_TRIO}" = "1") -AC_SUBST(WITH_TRIO) - dnl dnl Thread-related stuff dnl diff --git a/doc/apibuild.py b/doc/apibuild.py index f7e66df03..2e3882600 100755 --- a/doc/apibuild.py +++ b/doc/apibuild.py @@ -19,10 +19,6 @@ # C parser analysis code # ignored_files = { - "trio": "too many non standard macros", - "trio.c": "too many non standard macros", - "trionan.c": "too many non standard macros", - "triostr.c": "too many non standard macros", "config.h": "generated portability layer", "libxml.h": "internal only", "testOOM.c": "out of memory tester", diff --git a/include/libxml/xmlversion.h.in b/include/libxml/xmlversion.h.in index bdc27087c..abcf9c54c 100644 --- a/include/libxml/xmlversion.h.in +++ b/include/libxml/xmlversion.h.in @@ -60,31 +60,6 @@ XMLPUBFUN void xmlCheckVersion(int version); */ #define LIBXML_TEST_VERSION xmlCheckVersion(@LIBXML_VERSION_NUMBER@); -#ifndef VMS -#if @WITH_TRIO@ -/** - * WITH_TRIO: - * - * defined if the trio support need to be configured in - */ -#define WITH_TRIO -#else -/** - * WITHOUT_TRIO: - * - * defined if the trio support should not be configured in - */ -#define WITHOUT_TRIO -#endif -#else /* VMS */ -/** - * WITH_TRIO: - * - * defined if the trio support need to be configured in - */ -#define WITH_TRIO 1 -#endif /* VMS */ - /** * LIBXML_THREAD_ENABLED: * diff --git a/libxml.h b/libxml.h index 8d6b43a34..00404d2fa 100644 --- a/libxml.h +++ b/libxml.h @@ -38,11 +38,6 @@ #define SYSCONFDIR "/etc" #endif -#ifdef WITH_TRIO - #define TRIO_REPLACE_STDIO - #include "trio.h" -#endif - #if !defined(_WIN32) && \ !defined(__CYGWIN__) && \ (defined(__clang__) || \ diff --git a/python/libxml.c b/python/libxml.c index bf0480068..08e18940b 100644 --- a/python/libxml.c +++ b/python/libxml.c @@ -29,11 +29,6 @@ #include "libxml_wrap.h" #include "libxml2-py.h" -#if defined(WITH_TRIO) -#include "trio.h" -#define vsnprintf trio_vsnprintf -#endif - #if PY_MAJOR_VERSION >= 3 PyObject *PyInit_libxml2mod(void); diff --git a/trio.c b/trio.c deleted file mode 100644 index 31b3b3710..000000000 --- a/trio.c +++ /dev/null @@ -1,6892 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************* - * - * A note to trio contributors: - * - * Avoid heap allocation at all costs to ensure that the trio functions - * are async-safe. The exceptions are the printf/fprintf functions, which - * uses fputc, and the asprintf functions and the modifier, which - * by design are required to allocate form the heap. - * - ************************************************************************/ - -/* - * TODO: - * - Scan is probably too permissive about its modifiers. - * - C escapes in %#[] ? - * - Multibyte characters (done for format parsing, except scan groups) - * - Complex numbers? (C99 _Complex) - * - Boolean values? (C99 _Bool) - * - C99 NaN(n-char-sequence) missing. The n-char-sequence can be used - * to print the mantissa, e.g. NaN(0xc000000000000000) - * - Should we support the GNU %a alloc modifier? GNU has an ugly hack - * for %a, because C99 used %a for other purposes. If specified as - * %as or %a[ it is interpreted as the alloc modifier, otherwise as - * the C99 hex-float. This means that you cannot scan %as as a hex-float - * immediately followed by an 's'. - * - Scanning of collating symbols. - */ - -/************************************************************************* - * Trio include files - */ -#include "triodef.h" -#include "trio.h" -#include "triop.h" -#include "trionan.h" -#if !defined(TRIO_MINIMAL) -# include "triostr.h" -#endif - -/************************************************************************** - * - * Definitions - * - *************************************************************************/ - -#include -#include -#include - -#if (defined(__STDC_ISO_10646__) || defined(MB_LEN_MAX) \ - || defined(USE_MULTIBYTE) || TRIO_WIDECHAR) \ - && !defined(_WIN32_WCE) -# define TRIO_COMPILER_SUPPORTS_MULTIBYTE -# if !defined(MB_LEN_MAX) -# define MB_LEN_MAX 6 -# endif -#endif - -#if (defined(TRIO_COMPILER_MSVC) && (_MSC_VER >= 1100)) || defined(TRIO_COMPILER_BCB) -# define TRIO_COMPILER_SUPPORTS_MSVC_INT -#endif - -#if defined(_WIN32_WCE) -#include -#endif - -/************************************************************************* - * Generic definitions - */ - -#if !(defined(DEBUG) || defined(NDEBUG)) -# define NDEBUG -#endif - -#include -#include -#if !defined(TRIO_COMPILER_SUPPORTS_C99) -# define isblank(x) (((x)==32) || ((x)==9)) -#endif -#if defined(TRIO_COMPILER_ANCIENT) -# include -#else -# include -#endif -#include -#include - -#ifndef NULL -# define NULL 0 -#endif -#define NIL ((char)0) -#ifndef FALSE -# define FALSE (1 == 0) -# define TRUE (! FALSE) -#endif -#define BOOLEAN_T int - -/* mincore() can be used for debugging purposes */ -#define VALID(x) (NULL != (x)) - -#if TRIO_ERRORS - /* - * Encode the error code and the position. This is decoded - * with TRIO_ERROR_CODE and TRIO_ERROR_POSITION. - */ -# define TRIO_ERROR_RETURN(x,y) (- ((x) + ((y) << 8))) -#else -# define TRIO_ERROR_RETURN(x,y) (-1) -#endif - -#ifndef VA_LIST_IS_ARRAY -#define TRIO_VA_LIST_PTR va_list * -#define TRIO_VA_LIST_ADDR(l) (&(l)) -#define TRIO_VA_LIST_DEREF(l) (*(l)) -#else -#define TRIO_VA_LIST_PTR va_list -#define TRIO_VA_LIST_ADDR(l) (l) -#define TRIO_VA_LIST_DEREF(l) (l) -#endif - -typedef unsigned long trio_flags_t; - - -/************************************************************************* - * Platform specific definitions - */ -#if defined(TRIO_PLATFORM_UNIX) || defined(TRIO_PLATFORM_OS400) -# include -# include -# include -# define USE_LOCALE -#endif /* TRIO_PLATFORM_UNIX */ -#if defined(TRIO_PLATFORM_VMS) -# include -#endif -#if defined(TRIO_PLATFORM_WIN32) -# if defined(_WIN32_WCE) -# include -# else -# include -# define read _read -# define write _write -# endif -#endif /* TRIO_PLATFORM_WIN32 */ - -#if TRIO_WIDECHAR -# if defined(TRIO_COMPILER_SUPPORTS_ISO94) -# include -# include -typedef wchar_t trio_wchar_t; -typedef wint_t trio_wint_t; -# else -typedef char trio_wchar_t; -typedef int trio_wint_t; -# define WCONST(x) L ## x -# define WEOF EOF -# define iswalnum(x) isalnum(x) -# define iswalpha(x) isalpha(x) -# define iswblank(x) isblank(x) -# define iswcntrl(x) iscntrl(x) -# define iswdigit(x) isdigit(x) -# define iswgraph(x) isgraph(x) -# define iswlower(x) islower(x) -# define iswprint(x) isprint(x) -# define iswpunct(x) ispunct(x) -# define iswspace(x) isspace(x) -# define iswupper(x) isupper(x) -# define iswxdigit(x) isxdigit(x) -# endif -#endif - - -/************************************************************************* - * Compiler dependent definitions - */ - -/* Support for long long */ -#ifndef __cplusplus -# if !defined(USE_LONGLONG) -# if defined(TRIO_COMPILER_GCC) && !defined(__STRICT_ANSI__) -# define USE_LONGLONG -# elif defined(TRIO_COMPILER_SUNPRO) -# define USE_LONGLONG -# elif defined(_LONG_LONG) || defined(_LONGLONG) -# define USE_LONGLONG -# endif -# endif -#endif - -/* The extra long numbers */ -#if defined(USE_LONGLONG) -typedef signed long long int trio_longlong_t; -typedef unsigned long long int trio_ulonglong_t; -#elif defined(TRIO_COMPILER_SUPPORTS_MSVC_INT) -typedef signed __int64 trio_longlong_t; -typedef unsigned __int64 trio_ulonglong_t; -#else -typedef TRIO_SIGNED long int trio_longlong_t; -typedef unsigned long int trio_ulonglong_t; -#endif - -/* Maximal and fixed integer types */ -#if defined(TRIO_COMPILER_SUPPORTS_C99) && !defined( __VMS ) -# include -typedef intmax_t trio_intmax_t; -typedef uintmax_t trio_uintmax_t; -typedef int8_t trio_int8_t; -typedef int16_t trio_int16_t; -typedef int32_t trio_int32_t; -typedef int64_t trio_int64_t; -#elif defined(TRIO_COMPILER_SUPPORTS_UNIX98) || defined( __VMS ) -# include -#ifdef __VMS -typedef long long int intmax_t; -typedef unsigned long long int uintmax_t; -#endif -typedef intmax_t trio_intmax_t; -typedef uintmax_t trio_uintmax_t; -typedef int8_t trio_int8_t; -typedef int16_t trio_int16_t; -typedef int32_t trio_int32_t; -typedef int64_t trio_int64_t; -#elif defined(TRIO_COMPILER_SUPPORTS_MSVC_INT) -typedef trio_longlong_t trio_intmax_t; -typedef trio_ulonglong_t trio_uintmax_t; -typedef __int8 trio_int8_t; -typedef __int16 trio_int16_t; -typedef __int32 trio_int32_t; -typedef __int64 trio_int64_t; -#else -typedef trio_longlong_t trio_intmax_t; -typedef trio_ulonglong_t trio_uintmax_t; -# if defined(TRIO_INT8_T) -typedef TRIO_INT8_T trio_int8_t; -# else -typedef TRIO_SIGNED char trio_int8_t; -# endif -# if defined(TRIO_INT16_T) -typedef TRIO_INT16_T trio_int16_t; -# else -typedef TRIO_SIGNED short trio_int16_t; -# endif -# if defined(TRIO_INT32_T) -typedef TRIO_INT32_T trio_int32_t; -# else -typedef TRIO_SIGNED int trio_int32_t; -# endif -# if defined(TRIO_INT64_T) -typedef TRIO_INT64_T trio_int64_t; -# else -typedef trio_longlong_t trio_int64_t; -# endif -#endif - -#if (!(defined(TRIO_COMPILER_SUPPORTS_C99) \ - || defined(TRIO_COMPILER_SUPPORTS_UNIX01))) \ - && !defined(_WIN32_WCE) -# define floorl(x) floor((double)(x)) -# define fmodl(x,y) fmod((double)(x),(double)(y)) -# define powl(x,y) pow((double)(x),(double)(y)) -#endif - -#define TRIO_FABS(x) (((x) < 0.0) ? -(x) : (x)) - -/************************************************************************* - * Internal Definitions - */ - -#ifndef DECIMAL_DIG -# define DECIMAL_DIG DBL_DIG -#endif - -/* Long double sizes */ -#ifdef LDBL_DIG -# define MAX_MANTISSA_DIGITS LDBL_DIG -# define MAX_EXPONENT_DIGITS 4 -# define MAX_DOUBLE_DIGITS LDBL_MAX_10_EXP -#else -# define MAX_MANTISSA_DIGITS DECIMAL_DIG -# define MAX_EXPONENT_DIGITS 3 -# define MAX_DOUBLE_DIGITS DBL_MAX_10_EXP -#endif - -#if defined(TRIO_COMPILER_ANCIENT) || !defined(LDBL_DIG) -# undef LDBL_DIG -# undef LDBL_MANT_DIG -# undef LDBL_EPSILON -# define LDBL_DIG DBL_DIG -# define LDBL_MANT_DIG DBL_MANT_DIG -# define LDBL_EPSILON DBL_EPSILON -#endif - -/* The maximal number of digits is for base 2 */ -#define MAX_CHARS_IN(x) (sizeof(x) * CHAR_BIT) -/* The width of a pointer. The number of bits in a hex digit is 4 */ -#define POINTER_WIDTH ((sizeof("0x") - 1) + sizeof(trio_pointer_t) * CHAR_BIT / 4) - -/* Infinite and Not-A-Number for floating-point */ -#define INFINITE_LOWER "inf" -#define INFINITE_UPPER "INF" -#define LONG_INFINITE_LOWER "infinite" -#define LONG_INFINITE_UPPER "INFINITE" -#define NAN_LOWER "nan" -#define NAN_UPPER "NAN" - -#if !defined(HAVE_ISASCII) && !defined(isascii) -#ifndef __VMS -# define isascii(x) ((unsigned int)(x) < 128) -#endif -#endif - -/* Various constants */ -enum { - TYPE_PRINT = 1, - TYPE_SCAN = 2, - - /* Flags. FLAGS_LAST must be less than ULONG_MAX */ - FLAGS_NEW = 0, - FLAGS_STICKY = 1, - FLAGS_SPACE = 2 * FLAGS_STICKY, - FLAGS_SHOWSIGN = 2 * FLAGS_SPACE, - FLAGS_LEFTADJUST = 2 * FLAGS_SHOWSIGN, - FLAGS_ALTERNATIVE = 2 * FLAGS_LEFTADJUST, - FLAGS_SHORT = 2 * FLAGS_ALTERNATIVE, - FLAGS_SHORTSHORT = 2 * FLAGS_SHORT, - FLAGS_LONG = 2 * FLAGS_SHORTSHORT, - FLAGS_QUAD = 2 * FLAGS_LONG, - FLAGS_LONGDOUBLE = 2 * FLAGS_QUAD, - FLAGS_SIZE_T = 2 * FLAGS_LONGDOUBLE, - FLAGS_PTRDIFF_T = 2 * FLAGS_SIZE_T, - FLAGS_INTMAX_T = 2 * FLAGS_PTRDIFF_T, - FLAGS_NILPADDING = 2 * FLAGS_INTMAX_T, - FLAGS_UNSIGNED = 2 * FLAGS_NILPADDING, - FLAGS_UPPER = 2 * FLAGS_UNSIGNED, - FLAGS_WIDTH = 2 * FLAGS_UPPER, - FLAGS_WIDTH_PARAMETER = 2 * FLAGS_WIDTH, - FLAGS_PRECISION = 2 * FLAGS_WIDTH_PARAMETER, - FLAGS_PRECISION_PARAMETER = 2 * FLAGS_PRECISION, - FLAGS_BASE = 2 * FLAGS_PRECISION_PARAMETER, - FLAGS_BASE_PARAMETER = 2 * FLAGS_BASE, - FLAGS_FLOAT_E = 2 * FLAGS_BASE_PARAMETER, - FLAGS_FLOAT_G = 2 * FLAGS_FLOAT_E, - FLAGS_QUOTE = 2 * FLAGS_FLOAT_G, - FLAGS_WIDECHAR = 2 * FLAGS_QUOTE, - FLAGS_ALLOC = 2 * FLAGS_WIDECHAR, - FLAGS_IGNORE = 2 * FLAGS_ALLOC, - FLAGS_IGNORE_PARAMETER = 2 * FLAGS_IGNORE, - FLAGS_VARSIZE_PARAMETER = 2 * FLAGS_IGNORE_PARAMETER, - FLAGS_FIXED_SIZE = 2 * FLAGS_VARSIZE_PARAMETER, - FLAGS_LAST = FLAGS_FIXED_SIZE, - /* Reused flags */ - FLAGS_EXCLUDE = FLAGS_SHORT, - FLAGS_USER_DEFINED = FLAGS_IGNORE, - FLAGS_ROUNDING = FLAGS_INTMAX_T, - /* Compounded flags */ - FLAGS_ALL_VARSIZES = FLAGS_LONG | FLAGS_QUAD | FLAGS_INTMAX_T | FLAGS_PTRDIFF_T | FLAGS_SIZE_T, - FLAGS_ALL_SIZES = FLAGS_ALL_VARSIZES | FLAGS_SHORTSHORT | FLAGS_SHORT, - - NO_POSITION = -1, - NO_WIDTH = 0, - NO_PRECISION = -1, - NO_SIZE = -1, - - /* Do not change these */ - NO_BASE = -1, - MIN_BASE = 2, - MAX_BASE = 36, - BASE_BINARY = 2, - BASE_OCTAL = 8, - BASE_DECIMAL = 10, - BASE_HEX = 16, - - /* Maximal number of allowed parameters */ - MAX_PARAMETERS = 64, - /* Maximal number of characters in class */ - MAX_CHARACTER_CLASS = UCHAR_MAX + 1, - - /* Maximal string lengths for user-defined specifiers */ - MAX_USER_NAME = 64, - MAX_USER_DATA = 256, - - /* Maximal length of locale separator strings */ - MAX_LOCALE_SEPARATOR_LENGTH = MB_LEN_MAX, - /* Maximal number of integers in grouping */ - MAX_LOCALE_GROUPS = 64, - - /* Initial size of asprintf buffer */ - DYNAMIC_START_SIZE = 32 -}; - -#define NO_GROUPING ((int)CHAR_MAX) - -/* Fundamental formatting parameter types */ -#define FORMAT_UNKNOWN 0 -#define FORMAT_INT 1 -#define FORMAT_DOUBLE 2 -#define FORMAT_CHAR 3 -#define FORMAT_STRING 4 -#define FORMAT_POINTER 5 -#define FORMAT_COUNT 6 -#define FORMAT_PARAMETER 7 -#define FORMAT_GROUP 8 -#if TRIO_GNU -# define FORMAT_ERRNO 9 -#endif -#if TRIO_EXTENSION -# define FORMAT_USER_DEFINED 10 -#endif - -/* Character constants */ -#define CHAR_IDENTIFIER '%' -#define CHAR_BACKSLASH '\\' -#define CHAR_QUOTE '\"' -#define CHAR_ADJUST ' ' - -/* Character class expressions */ -#define CLASS_ALNUM "[:alnum:]" -#define CLASS_ALPHA "[:alpha:]" -#define CLASS_BLANK "[:blank:]" -#define CLASS_CNTRL "[:cntrl:]" -#define CLASS_DIGIT "[:digit:]" -#define CLASS_GRAPH "[:graph:]" -#define CLASS_LOWER "[:lower:]" -#define CLASS_PRINT "[:print:]" -#define CLASS_PUNCT "[:punct:]" -#define CLASS_SPACE "[:space:]" -#define CLASS_UPPER "[:upper:]" -#define CLASS_XDIGIT "[:xdigit:]" - -/* - * SPECIFIERS: - * - * - * a Hex-float - * A Hex-float - * c Character - * C Widechar character (wint_t) - * d Decimal - * e Float - * E Float - * F Float - * F Float - * g Float - * G Float - * i Integer - * m Error message - * n Count - * o Octal - * p Pointer - * s String - * S Widechar string (wchar_t *) - * u Unsigned - * x Hex - * X Hex - * [] Group - * <> User-defined - * - * Reserved: - * - * D Binary Coded Decimal %D(length,precision) (OS/390) - */ -#define SPECIFIER_CHAR 'c' -#define SPECIFIER_STRING 's' -#define SPECIFIER_DECIMAL 'd' -#define SPECIFIER_INTEGER 'i' -#define SPECIFIER_UNSIGNED 'u' -#define SPECIFIER_OCTAL 'o' -#define SPECIFIER_HEX 'x' -#define SPECIFIER_HEX_UPPER 'X' -#define SPECIFIER_FLOAT_E 'e' -#define SPECIFIER_FLOAT_E_UPPER 'E' -#define SPECIFIER_FLOAT_F 'f' -#define SPECIFIER_FLOAT_F_UPPER 'F' -#define SPECIFIER_FLOAT_G 'g' -#define SPECIFIER_FLOAT_G_UPPER 'G' -#define SPECIFIER_POINTER 'p' -#define SPECIFIER_GROUP '[' -#define SPECIFIER_UNGROUP ']' -#define SPECIFIER_COUNT 'n' -#if TRIO_UNIX98 -# define SPECIFIER_CHAR_UPPER 'C' -# define SPECIFIER_STRING_UPPER 'S' -#endif -#if TRIO_C99 -# define SPECIFIER_HEXFLOAT 'a' -# define SPECIFIER_HEXFLOAT_UPPER 'A' -#endif -#if TRIO_GNU -# define SPECIFIER_ERRNO 'm' -#endif -#if TRIO_EXTENSION -# define SPECIFIER_BINARY 'b' -# define SPECIFIER_BINARY_UPPER 'B' -# define SPECIFIER_USER_DEFINED_BEGIN '<' -# define SPECIFIER_USER_DEFINED_END '>' -# define SPECIFIER_USER_DEFINED_SEPARATOR ':' -#endif - -/* - * QUALIFIERS: - * - * - * Numbers = d,i,o,u,x,X - * Float = a,A,e,E,f,F,g,G - * String = s - * Char = c - * - * - * 9$ Position - * Use the 9th parameter. 9 can be any number between 1 and - * the maximal argument - * - * 9 Width - * Set width to 9. 9 can be any number, but must not be postfixed - * by '$' - * - * h Short - * Numbers: - * (unsigned) short int - * - * hh Short short - * Numbers: - * (unsigned) char - * - * l Long - * Numbers: - * (unsigned) long int - * String: - * as the S specifier - * Char: - * as the C specifier - * - * ll Long Long - * Numbers: - * (unsigned) long long int - * - * L Long Double - * Float - * long double - * - * # Alternative - * Float: - * Decimal-point is always present - * String: - * non-printable characters are handled as \number - * - * Spacing - * - * + Sign - * - * - Alignment - * - * . Precision - * - * * Parameter - * print: use parameter - * scan: no parameter (ignore) - * - * q Quad - * - * Z size_t - * - * w Widechar - * - * ' Thousands/quote - * Numbers: - * Integer part grouped in thousands - * Binary numbers: - * Number grouped in nibbles (4 bits) - * String: - * Quoted string - * - * j intmax_t - * t prtdiff_t - * z size_t - * - * ! Sticky - * @ Parameter (for both print and scan) - * - * I n-bit Integer - * Numbers: - * The following options exists - * I8 = 8-bit integer - * I16 = 16-bit integer - * I32 = 32-bit integer - * I64 = 64-bit integer - */ -#define QUALIFIER_POSITION '$' -#define QUALIFIER_SHORT 'h' -#define QUALIFIER_LONG 'l' -#define QUALIFIER_LONG_UPPER 'L' -#define QUALIFIER_ALTERNATIVE '#' -#define QUALIFIER_SPACE ' ' -#define QUALIFIER_PLUS '+' -#define QUALIFIER_MINUS '-' -#define QUALIFIER_DOT '.' -#define QUALIFIER_STAR '*' -#define QUALIFIER_CIRCUMFLEX '^' /* For scanlists */ -#if TRIO_C99 -# define QUALIFIER_SIZE_T 'z' -# define QUALIFIER_PTRDIFF_T 't' -# define QUALIFIER_INTMAX_T 'j' -#endif -#if TRIO_BSD || TRIO_GNU -# define QUALIFIER_QUAD 'q' -#endif -#if TRIO_GNU -# define QUALIFIER_SIZE_T_UPPER 'Z' -#endif -#if TRIO_MISC -# define QUALIFIER_WIDECHAR 'w' -#endif -#if TRIO_MICROSOFT -# define QUALIFIER_FIXED_SIZE 'I' -#endif -#if TRIO_EXTENSION -# define QUALIFIER_QUOTE '\'' -# define QUALIFIER_STICKY '!' -# define QUALIFIER_VARSIZE '&' /* This should remain undocumented */ -# define QUALIFIER_PARAM '@' /* Experimental */ -# define QUALIFIER_COLON ':' /* For scanlists */ -# define QUALIFIER_EQUAL '=' /* For scanlists */ -# define QUALIFIER_ROUNDING_UPPER 'R' -#endif - - -/************************************************************************* - * - * Internal Structures - * - *************************************************************************/ - -/* Parameters */ -typedef struct { - /* An indication of which entry in the data union is used */ - int type; - /* The flags */ - trio_flags_t flags; - /* The width qualifier */ - int width; - /* The precision qualifier */ - int precision; - /* The base qualifier */ - int base; - /* The size for the variable size qualifier */ - int varsize; - /* The marker of the end of the specifier */ - int indexAfterSpecifier; - /* The data from the argument list */ - union { - char *string; -#if TRIO_WIDECHAR - trio_wchar_t *wstring; -#endif - trio_pointer_t pointer; - union { - trio_intmax_t as_signed; - trio_uintmax_t as_unsigned; - } number; - double doubleNumber; - double *doublePointer; - trio_long_double_t longdoubleNumber; - trio_long_double_t *longdoublePointer; - int errorNumber; - } data; - /* For the user-defined specifier */ - char user_name[MAX_USER_NAME]; - char user_data[MAX_USER_DATA]; -} trio_parameter_t; - -/* Container for customized functions */ -typedef struct { - union { - trio_outstream_t out; - trio_instream_t in; - } stream; - trio_pointer_t closure; -} trio_custom_t; - -/* General trio "class" */ -typedef struct _trio_class_t { - /* - * The function to write characters to a stream. - */ - void (*OutStream) TRIO_PROTO((struct _trio_class_t *, int)); - /* - * The function to read characters from a stream. - */ - void (*InStream) TRIO_PROTO((struct _trio_class_t *, int *)); - /* - * The current location in the stream. - */ - trio_pointer_t location; - /* - * The character currently being processed. - */ - int current; - /* - * The number of characters that would have been written/read - * if there had been sufficient space. - */ - int processed; - /* - * The number of characters that are actually written/read. - * Processed and committed will only differ for the *nprintf - * and *nscanf functions. - */ - int committed; - /* - * The upper limit of characters that may be written/read. - */ - int max; - /* - * The last output error that was detected. - */ - int error; -} trio_class_t; - -/* References (for user-defined callbacks) */ -typedef struct _trio_reference_t { - trio_class_t *data; - trio_parameter_t *parameter; -} trio_reference_t; - -/* Registered entries (for user-defined callbacks) */ -typedef struct _trio_userdef_t { - struct _trio_userdef_t *next; - trio_callback_t callback; - char *name; -} trio_userdef_t; - -/************************************************************************* - * - * Internal Variables - * - *************************************************************************/ - -static TRIO_CONST char rcsid[] = "@(#)$Id$"; - -/* - * Need this to workaround a parser bug in HP C/iX compiler that fails - * to resolves macro definitions that includes type 'long double', - * e.g: va_arg(arg_ptr, long double) - */ -#if defined(TRIO_PLATFORM_MPEIX) -static TRIO_CONST trio_long_double_t ___dummy_long_double = 0; -#endif - -static TRIO_CONST char internalNullString[] = "(nil)"; - -#if defined(USE_LOCALE) -static struct lconv *internalLocaleValues = NULL; -#endif - -/* - * UNIX98 says "in a locale where the radix character is not defined, - * the radix character defaults to a period (.)" - */ -static int internalDecimalPointLength = 1; -static int internalThousandSeparatorLength = 1; -static char internalDecimalPoint = '.'; -static char internalDecimalPointString[MAX_LOCALE_SEPARATOR_LENGTH + 1] = "."; -static char internalThousandSeparator[MAX_LOCALE_SEPARATOR_LENGTH + 1] = ","; -static char internalGrouping[MAX_LOCALE_GROUPS] = { (char)NO_GROUPING }; - -static TRIO_CONST char internalDigitsLower[] = "0123456789abcdefghijklmnopqrstuvwxyz"; -static TRIO_CONST char internalDigitsUpper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -static BOOLEAN_T internalDigitsUnconverted = TRUE; -static int internalDigitArray[128]; -#if TRIO_EXTENSION -static BOOLEAN_T internalCollationUnconverted = TRUE; -static char internalCollationArray[MAX_CHARACTER_CLASS][MAX_CHARACTER_CLASS]; -#endif - -#if TRIO_EXTENSION -static TRIO_VOLATILE trio_callback_t internalEnterCriticalRegion = NULL; -static TRIO_VOLATILE trio_callback_t internalLeaveCriticalRegion = NULL; -static trio_userdef_t *internalUserDef = NULL; -#endif - - -/************************************************************************* - * - * Internal Functions - * - ************************************************************************/ - -#if defined(TRIO_MINIMAL) -# define TRIO_STRING_PUBLIC static -# include "triostr.c" -#endif /* defined(TRIO_MINIMAL) */ - -/************************************************************************* - * TrioIsQualifier - * - * Description: - * Remember to add all new qualifiers to this function. - * QUALIFIER_POSITION must not be added. - */ -TRIO_PRIVATE BOOLEAN_T -TrioIsQualifier -TRIO_ARGS1((character), - TRIO_CONST char character) -{ - /* QUALIFIER_POSITION is not included */ - switch (character) - { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case QUALIFIER_PLUS: - case QUALIFIER_MINUS: - case QUALIFIER_SPACE: - case QUALIFIER_DOT: - case QUALIFIER_STAR: - case QUALIFIER_ALTERNATIVE: - case QUALIFIER_SHORT: - case QUALIFIER_LONG: - case QUALIFIER_LONG_UPPER: - case QUALIFIER_CIRCUMFLEX: -#if defined(QUALIFIER_SIZE_T) - case QUALIFIER_SIZE_T: -#endif -#if defined(QUALIFIER_PTRDIFF_T) - case QUALIFIER_PTRDIFF_T: -#endif -#if defined(QUALIFIER_INTMAX_T) - case QUALIFIER_INTMAX_T: -#endif -#if defined(QUALIFIER_QUAD) - case QUALIFIER_QUAD: -#endif -#if defined(QUALIFIER_SIZE_T_UPPER) - case QUALIFIER_SIZE_T_UPPER: -#endif -#if defined(QUALIFIER_WIDECHAR) - case QUALIFIER_WIDECHAR: -#endif -#if defined(QUALIFIER_QUOTE) - case QUALIFIER_QUOTE: -#endif -#if defined(QUALIFIER_STICKY) - case QUALIFIER_STICKY: -#endif -#if defined(QUALIFIER_VARSIZE) - case QUALIFIER_VARSIZE: -#endif -#if defined(QUALIFIER_PARAM) - case QUALIFIER_PARAM: -#endif -#if defined(QUALIFIER_FIXED_SIZE) - case QUALIFIER_FIXED_SIZE: -#endif -#if defined(QUALIFIER_ROUNDING_UPPER) - case QUALIFIER_ROUNDING_UPPER: -#endif - return TRUE; - default: - return FALSE; - } -} - -/************************************************************************* - * TrioSetLocale - */ -#if defined(USE_LOCALE) -TRIO_PRIVATE void -TrioSetLocale(TRIO_NOARGS) -{ - internalLocaleValues = (struct lconv *)localeconv(); - if (internalLocaleValues) - { - if ((internalLocaleValues->decimal_point) && - (internalLocaleValues->decimal_point[0] != NIL)) - { - internalDecimalPointLength = trio_length(internalLocaleValues->decimal_point); - if (internalDecimalPointLength == 1) - { - internalDecimalPoint = internalLocaleValues->decimal_point[0]; - } - else - { - internalDecimalPoint = NIL; - trio_copy_max(internalDecimalPointString, - sizeof(internalDecimalPointString), - internalLocaleValues->decimal_point); - } - } - if ((internalLocaleValues->thousands_sep) && - (internalLocaleValues->thousands_sep[0] != NIL)) - { - trio_copy_max(internalThousandSeparator, - sizeof(internalThousandSeparator), - internalLocaleValues->thousands_sep); - internalThousandSeparatorLength = trio_length(internalThousandSeparator); - } - if ((internalLocaleValues->grouping) && - (internalLocaleValues->grouping[0] != NIL)) - { - trio_copy_max(internalGrouping, - sizeof(internalGrouping), - internalLocaleValues->grouping); - } - } -} -#endif /* defined(USE_LOCALE) */ - -TRIO_PRIVATE int -TrioCalcThousandSeparatorLength -TRIO_ARGS1((digits), - int digits) -{ -#if TRIO_EXTENSION - int count = 0; - int step = NO_GROUPING; - char *groupingPointer = internalGrouping; - - while (digits > 0) - { - if (*groupingPointer == CHAR_MAX) - { - /* Disable grouping */ - break; /* while */ - } - else if (*groupingPointer == 0) - { - /* Repeat last group */ - if (step == NO_GROUPING) - { - /* Error in locale */ - break; /* while */ - } - } - else - { - step = *groupingPointer++; - } - if (digits > step) - count += internalThousandSeparatorLength; - digits -= step; - } - return count; -#else - return 0; -#endif -} - -TRIO_PRIVATE BOOLEAN_T -TrioFollowedBySeparator -TRIO_ARGS1((position), - int position) -{ -#if TRIO_EXTENSION - int step = 0; - char *groupingPointer = internalGrouping; - - position--; - if (position == 0) - return FALSE; - while (position > 0) - { - if (*groupingPointer == CHAR_MAX) - { - /* Disable grouping */ - break; /* while */ - } - else if (*groupingPointer != 0) - { - step = *groupingPointer++; - } - if (step == 0) - break; - position -= step; - } - return (position == 0); -#else - return FALSE; -#endif -} - -/************************************************************************* - * TrioGetPosition - * - * Get the %n$ position. - */ -TRIO_PRIVATE int -TrioGetPosition -TRIO_ARGS2((format, indexPointer), - TRIO_CONST char *format, - int *indexPointer) -{ -#if TRIO_UNIX98 - char *tmpformat; - int number = 0; - int index = *indexPointer; - - number = (int)trio_to_long(&format[index], &tmpformat, BASE_DECIMAL); - index = (int)(tmpformat - format); - if ((number != 0) && (QUALIFIER_POSITION == format[index++])) - { - *indexPointer = index; - /* - * number is decreased by 1, because n$ starts from 1, whereas - * the array it is indexing starts from 0. - */ - return number - 1; - } -#endif - return NO_POSITION; -} - -#if TRIO_EXTENSION -/************************************************************************* - * TrioFindNamespace - * - * Find registered user-defined specifier. - * The prev argument is used for optimization only. - */ -TRIO_PRIVATE trio_userdef_t * -TrioFindNamespace -TRIO_ARGS2((name, prev), - TRIO_CONST char *name, - trio_userdef_t **prev) -{ - trio_userdef_t *def; - - if (internalEnterCriticalRegion) - (void)internalEnterCriticalRegion(NULL); - - for (def = internalUserDef; def; def = def->next) - { - /* Case-sensitive string comparison */ - if (trio_equal_case(def->name, name)) - break; - - if (prev) - *prev = def; - } - - if (internalLeaveCriticalRegion) - (void)internalLeaveCriticalRegion(NULL); - - return def; -} -#endif - -/************************************************************************* - * TrioPower - * - * Description: - * Calculate pow(base, exponent), where number and exponent are integers. - */ -TRIO_PRIVATE trio_long_double_t -TrioPower -TRIO_ARGS2((number, exponent), - int number, - int exponent) -{ - trio_long_double_t result; - - if (number == 10) - { - switch (exponent) - { - /* Speed up calculation of common cases */ - case 0: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E-1); - break; - case 1: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+0); - break; - case 2: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+1); - break; - case 3: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+2); - break; - case 4: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+3); - break; - case 5: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+4); - break; - case 6: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+5); - break; - case 7: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+6); - break; - case 8: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+7); - break; - case 9: - result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+8); - break; - default: - result = powl((trio_long_double_t)number, - (trio_long_double_t)exponent); - break; - } - } - else - { - return powl((trio_long_double_t)number, (trio_long_double_t)exponent); - } - return result; -} - -/************************************************************************* - * TrioLogarithm - */ -TRIO_PRIVATE double -TrioLogarithm -TRIO_ARGS2((number, base), - double number, - int base) -{ - double result; - - if (number <= 0.0) - { - /* xlC crashes on log(0) */ - result = (number == 0.0) ? trio_ninf() : trio_nan(); - } - else - { - if (base == 10) - { - result = log10(number); - } - else - { - result = log10(number) / log10((double)base); - } - } - return result; -} - -/************************************************************************* - * TrioLogarithmBase - */ -TRIO_PRIVATE double -TrioLogarithmBase -TRIO_ARGS1((base), - int base) -{ - switch (base) - { - case BASE_BINARY : return 1.0; - case BASE_OCTAL : return 3.0; - case BASE_DECIMAL: return 3.321928094887362345; - case BASE_HEX : return 4.0; - default : return TrioLogarithm((double)base, 2); - } -} - -/************************************************************************* - * TrioParse - * - * Description: - * Parse the format string - */ -TRIO_PRIVATE int -TrioParse -TRIO_ARGS5((type, format, parameters, arglist, argarray), - int type, - TRIO_CONST char *format, - trio_parameter_t *parameters, - TRIO_VA_LIST_PTR arglist, - trio_pointer_t *argarray) -{ - /* Count the number of times a parameter is referenced */ - unsigned short usedEntries[MAX_PARAMETERS]; - /* Parameter counters */ - int parameterPosition; - int currentParam; - int maxParam = -1; - /* Utility variables */ - trio_flags_t flags; - int width; - int precision; - int varsize; - int base; - int index; /* Index into formatting string */ - int dots; /* Count number of dots in modifier part */ - BOOLEAN_T positional; /* Does the specifier have a positional? */ - BOOLEAN_T gotSticky = FALSE; /* Are there any sticky modifiers at all? */ - /* - * indices specifies the order in which the parameters must be - * read from the va_args (this is necessary to handle positionals) - */ - int indices[MAX_PARAMETERS]; - int pos = 0; - /* Various variables */ - char ch; -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - int charlen; -#endif - int save_errno; - int i = -1; - int num; - char *tmpformat; - - /* One and only one of arglist and argarray must be used */ - assert((arglist != NULL) ^ (argarray != NULL)); - - /* - * The 'parameters' array is not initialized, but we need to - * know which entries we have used. - */ - memset(usedEntries, 0, sizeof(usedEntries)); - - save_errno = errno; - index = 0; - parameterPosition = 0; -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - (void)mblen(NULL, 0); -#endif - - while (format[index]) - { -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - if (! isascii(format[index])) - { - /* - * Multibyte characters cannot be legal specifiers or - * modifiers, so we skip over them. - */ - charlen = mblen(&format[index], MB_LEN_MAX); - index += (charlen > 0) ? charlen : 1; - continue; /* while */ - } -#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ - if (CHAR_IDENTIFIER == format[index++]) - { - if (CHAR_IDENTIFIER == format[index]) - { - index++; - continue; /* while */ - } - - flags = FLAGS_NEW; - dots = 0; - currentParam = TrioGetPosition(format, &index); - positional = (NO_POSITION != currentParam); - if (!positional) - { - /* We have no positional, get the next counter */ - currentParam = parameterPosition; - } - if(currentParam >= MAX_PARAMETERS) - { - /* Bail out completely to make the error more obvious */ - return TRIO_ERROR_RETURN(TRIO_ETOOMANY, index); - } - - if (currentParam > maxParam) - maxParam = currentParam; - - /* Default values */ - width = NO_WIDTH; - precision = NO_PRECISION; - base = NO_BASE; - varsize = NO_SIZE; - - while (TrioIsQualifier(format[index])) - { - ch = format[index++]; - - switch (ch) - { - case QUALIFIER_SPACE: - flags |= FLAGS_SPACE; - break; - - case QUALIFIER_PLUS: - flags |= FLAGS_SHOWSIGN; - break; - - case QUALIFIER_MINUS: - flags |= FLAGS_LEFTADJUST; - flags &= ~FLAGS_NILPADDING; - break; - - case QUALIFIER_ALTERNATIVE: - flags |= FLAGS_ALTERNATIVE; - break; - - case QUALIFIER_DOT: - if (dots == 0) /* Precision */ - { - dots++; - - /* Skip if no precision */ - if (QUALIFIER_DOT == format[index]) - break; - - /* After the first dot we have the precision */ - flags |= FLAGS_PRECISION; - if ((QUALIFIER_STAR == format[index]) -#if defined(QUALIFIER_PARAM) - || (QUALIFIER_PARAM == format[index]) -#endif - ) - { - index++; - flags |= FLAGS_PRECISION_PARAMETER; - - precision = TrioGetPosition(format, &index); - if (precision == NO_POSITION) - { - parameterPosition++; - if (positional) - precision = parameterPosition; - else - { - precision = currentParam; - currentParam = precision + 1; - } - } - else - { - if (! positional) - currentParam = precision + 1; - if (width > maxParam) - maxParam = precision; - } - if (currentParam > maxParam) - maxParam = currentParam; - } - else - { - precision = trio_to_long(&format[index], - &tmpformat, - BASE_DECIMAL); - index = (int)(tmpformat - format); - } - } - else if (dots == 1) /* Base */ - { - dots++; - - /* After the second dot we have the base */ - flags |= FLAGS_BASE; - if ((QUALIFIER_STAR == format[index]) -#if defined(QUALIFIER_PARAM) - || (QUALIFIER_PARAM == format[index]) -#endif - ) - { - index++; - flags |= FLAGS_BASE_PARAMETER; - base = TrioGetPosition(format, &index); - if (base == NO_POSITION) - { - parameterPosition++; - if (positional) - base = parameterPosition; - else - { - base = currentParam; - currentParam = base + 1; - } - } - else - { - if (! positional) - currentParam = base + 1; - if (base > maxParam) - maxParam = base; - } - if (currentParam > maxParam) - maxParam = currentParam; - } - else - { - base = trio_to_long(&format[index], - &tmpformat, - BASE_DECIMAL); - if (base > MAX_BASE) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - index = (int)(tmpformat - format); - } - } - else - { - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - break; /* QUALIFIER_DOT */ - -#if defined(QUALIFIER_PARAM) - case QUALIFIER_PARAM: - type = TYPE_PRINT; - /* FALLTHROUGH */ -#endif - case QUALIFIER_STAR: - /* This has different meanings for print and scan */ - if (TYPE_PRINT == type) - { - /* Read with from parameter */ - flags |= (FLAGS_WIDTH | FLAGS_WIDTH_PARAMETER); - width = TrioGetPosition(format, &index); - if (width == NO_POSITION) - { - parameterPosition++; - if (positional) - width = parameterPosition; - else - { - width = currentParam; - currentParam = width + 1; - } - } - else - { - if (! positional) - currentParam = width + 1; - if (width > maxParam) - maxParam = width; - } - if (currentParam > maxParam) - maxParam = currentParam; - } - else - { - /* Scan, but do not store result */ - flags |= FLAGS_IGNORE; - } - - break; /* QUALIFIER_STAR */ - - case '0': - if (! (flags & FLAGS_LEFTADJUST)) - flags |= FLAGS_NILPADDING; - /* FALLTHROUGH */ - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - flags |= FLAGS_WIDTH; - /* &format[index - 1] is used to "rewind" the read - * character from format - */ - width = trio_to_long(&format[index - 1], - &tmpformat, - BASE_DECIMAL); - index = (int)(tmpformat - format); - break; - - case QUALIFIER_SHORT: - if (flags & FLAGS_SHORTSHORT) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - else if (flags & FLAGS_SHORT) - flags |= FLAGS_SHORTSHORT; - else - flags |= FLAGS_SHORT; - break; - - case QUALIFIER_LONG: - if (flags & FLAGS_QUAD) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - else if (flags & FLAGS_LONG) - flags |= FLAGS_QUAD; - else - flags |= FLAGS_LONG; - break; - - case QUALIFIER_LONG_UPPER: - flags |= FLAGS_LONGDOUBLE; - break; - -#if defined(QUALIFIER_SIZE_T) - case QUALIFIER_SIZE_T: - flags |= FLAGS_SIZE_T; - /* Modify flags for later truncation of number */ - if (sizeof(size_t) == sizeof(trio_ulonglong_t)) - flags |= FLAGS_QUAD; - else if (sizeof(size_t) == sizeof(long)) - flags |= FLAGS_LONG; - break; -#endif - -#if defined(QUALIFIER_PTRDIFF_T) - case QUALIFIER_PTRDIFF_T: - flags |= FLAGS_PTRDIFF_T; - if (sizeof(ptrdiff_t) == sizeof(trio_ulonglong_t)) - flags |= FLAGS_QUAD; - else if (sizeof(ptrdiff_t) == sizeof(long)) - flags |= FLAGS_LONG; - break; -#endif - -#if defined(QUALIFIER_INTMAX_T) - case QUALIFIER_INTMAX_T: - flags |= FLAGS_INTMAX_T; - if (sizeof(trio_intmax_t) == sizeof(trio_ulonglong_t)) - flags |= FLAGS_QUAD; - else if (sizeof(trio_intmax_t) == sizeof(long)) - flags |= FLAGS_LONG; - break; -#endif - -#if defined(QUALIFIER_QUAD) - case QUALIFIER_QUAD: - flags |= FLAGS_QUAD; - break; -#endif - -#if defined(QUALIFIER_FIXED_SIZE) - case QUALIFIER_FIXED_SIZE: - if (flags & FLAGS_FIXED_SIZE) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - - if (flags & (FLAGS_ALL_SIZES | FLAGS_LONGDOUBLE | - FLAGS_WIDECHAR | FLAGS_VARSIZE_PARAMETER)) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - - if ((format[index] == '6') && - (format[index + 1] == '4')) - { - varsize = sizeof(trio_int64_t); - index += 2; - } - else if ((format[index] == '3') && - (format[index + 1] == '2')) - { - varsize = sizeof(trio_int32_t); - index += 2; - } - else if ((format[index] == '1') && - (format[index + 1] == '6')) - { - varsize = sizeof(trio_int16_t); - index += 2; - } - else if (format[index] == '8') - { - varsize = sizeof(trio_int8_t); - index++; - } - else - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - - flags |= FLAGS_FIXED_SIZE; - break; -#endif - -#if defined(QUALIFIER_WIDECHAR) - case QUALIFIER_WIDECHAR: - flags |= FLAGS_WIDECHAR; - break; -#endif - -#if defined(QUALIFIER_SIZE_T_UPPER) - case QUALIFIER_SIZE_T_UPPER: - break; -#endif - -#if defined(QUALIFIER_QUOTE) - case QUALIFIER_QUOTE: - flags |= FLAGS_QUOTE; - break; -#endif - -#if defined(QUALIFIER_STICKY) - case QUALIFIER_STICKY: - flags |= FLAGS_STICKY; - gotSticky = TRUE; - break; -#endif - -#if defined(QUALIFIER_VARSIZE) - case QUALIFIER_VARSIZE: - flags |= FLAGS_VARSIZE_PARAMETER; - parameterPosition++; - if (positional) - varsize = parameterPosition; - else - { - varsize = currentParam; - currentParam = varsize + 1; - } - if (currentParam > maxParam) - maxParam = currentParam; - break; -#endif - -#if defined(QUALIFIER_ROUNDING_UPPER) - case QUALIFIER_ROUNDING_UPPER: - flags |= FLAGS_ROUNDING; - break; -#endif - - default: - /* Bail out completely to make the error more obvious */ - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - } /* while qualifier */ - - /* - * Parameters only need the type and value. The value is - * read later. - */ - if (flags & FLAGS_WIDTH_PARAMETER) - { - usedEntries[width] += 1; - parameters[pos].type = FORMAT_PARAMETER; - parameters[pos].flags = 0; - indices[width] = pos; - width = pos++; - } - if (flags & FLAGS_PRECISION_PARAMETER) - { - usedEntries[precision] += 1; - parameters[pos].type = FORMAT_PARAMETER; - parameters[pos].flags = 0; - indices[precision] = pos; - precision = pos++; - } - if (flags & FLAGS_BASE_PARAMETER) - { - usedEntries[base] += 1; - parameters[pos].type = FORMAT_PARAMETER; - parameters[pos].flags = 0; - indices[base] = pos; - base = pos++; - } - if (flags & FLAGS_VARSIZE_PARAMETER) - { - usedEntries[varsize] += 1; - parameters[pos].type = FORMAT_PARAMETER; - parameters[pos].flags = 0; - indices[varsize] = pos; - varsize = pos++; - } - - indices[currentParam] = pos; - - switch (format[index++]) - { -#if defined(SPECIFIER_CHAR_UPPER) - case SPECIFIER_CHAR_UPPER: - flags |= FLAGS_WIDECHAR; - /* FALLTHROUGH */ -#endif - case SPECIFIER_CHAR: - if (flags & FLAGS_LONG) - flags |= FLAGS_WIDECHAR; - else if (flags & FLAGS_SHORT) - flags &= ~FLAGS_WIDECHAR; - parameters[pos].type = FORMAT_CHAR; - break; - -#if defined(SPECIFIER_STRING_UPPER) - case SPECIFIER_STRING_UPPER: - flags |= FLAGS_WIDECHAR; - /* FALLTHROUGH */ -#endif - case SPECIFIER_STRING: - if (flags & FLAGS_LONG) - flags |= FLAGS_WIDECHAR; - else if (flags & FLAGS_SHORT) - flags &= ~FLAGS_WIDECHAR; - parameters[pos].type = FORMAT_STRING; - break; - - case SPECIFIER_GROUP: - if (TYPE_SCAN == type) - { - int depth = 1; - parameters[pos].type = FORMAT_GROUP; - if (format[index] == QUALIFIER_CIRCUMFLEX) - index++; - if (format[index] == SPECIFIER_UNGROUP) - index++; - if (format[index] == QUALIFIER_MINUS) - index++; - /* Skip nested brackets */ - while (format[index] != NIL) - { - if (format[index] == SPECIFIER_GROUP) - { - depth++; - } - else if (format[index] == SPECIFIER_UNGROUP) - { - if (--depth <= 0) - { - index++; - break; - } - } - index++; - } - } - break; - - case SPECIFIER_INTEGER: - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_UNSIGNED: - flags |= FLAGS_UNSIGNED; - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_DECIMAL: - /* Disable base modifier */ - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_DECIMAL; - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_OCTAL: - flags |= FLAGS_UNSIGNED; - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_OCTAL; - parameters[pos].type = FORMAT_INT; - break; - -#if defined(SPECIFIER_BINARY) - case SPECIFIER_BINARY_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_BINARY: - flags |= FLAGS_NILPADDING; - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_BINARY; - parameters[pos].type = FORMAT_INT; - break; -#endif - - case SPECIFIER_HEX_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_HEX: - flags |= FLAGS_UNSIGNED; - flags &= ~FLAGS_BASE_PARAMETER; - base = BASE_HEX; - parameters[pos].type = FORMAT_INT; - break; - - case SPECIFIER_FLOAT_E_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_FLOAT_E: - flags |= FLAGS_FLOAT_E; - parameters[pos].type = FORMAT_DOUBLE; - break; - - case SPECIFIER_FLOAT_G_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_FLOAT_G: - flags |= FLAGS_FLOAT_G; - parameters[pos].type = FORMAT_DOUBLE; - break; - - case SPECIFIER_FLOAT_F_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ - case SPECIFIER_FLOAT_F: - parameters[pos].type = FORMAT_DOUBLE; - break; - - case SPECIFIER_POINTER: - if (sizeof(trio_pointer_t) == sizeof(trio_ulonglong_t)) - flags |= FLAGS_QUAD; - else if (sizeof(trio_pointer_t) == sizeof(long)) - flags |= FLAGS_LONG; - parameters[pos].type = FORMAT_POINTER; - break; - - case SPECIFIER_COUNT: - parameters[pos].type = FORMAT_COUNT; - break; - -#if defined(SPECIFIER_HEXFLOAT) -# if defined(SPECIFIER_HEXFLOAT_UPPER) - case SPECIFIER_HEXFLOAT_UPPER: - flags |= FLAGS_UPPER; - /* FALLTHROUGH */ -# endif - case SPECIFIER_HEXFLOAT: - base = BASE_HEX; - parameters[pos].type = FORMAT_DOUBLE; - break; -#endif - -#if defined(FORMAT_ERRNO) - case SPECIFIER_ERRNO: - parameters[pos].type = FORMAT_ERRNO; - break; -#endif - -#if defined(SPECIFIER_USER_DEFINED_BEGIN) - case SPECIFIER_USER_DEFINED_BEGIN: - { - unsigned int max; - int without_namespace = TRUE; - - parameters[pos].type = FORMAT_USER_DEFINED; - parameters[pos].user_name[0] = NIL; - tmpformat = (char *)&format[index]; - - while ((ch = format[index])) - { - index++; - if (ch == SPECIFIER_USER_DEFINED_END) - { - if (without_namespace) - { - /* We must get the handle first */ - parameters[pos].type = FORMAT_PARAMETER; - parameters[pos].indexAfterSpecifier = index; - parameters[pos].flags = FLAGS_USER_DEFINED; - /* Adjust parameters for insertion of new one */ - pos++; - usedEntries[currentParam] += 1; - parameters[pos].type = FORMAT_USER_DEFINED; - currentParam++; - indices[currentParam] = pos; - if (currentParam > maxParam) - maxParam = currentParam; - } - /* Copy the user data */ - max = (unsigned int)(&format[index] - tmpformat); - if (max > MAX_USER_DATA) - max = MAX_USER_DATA; - trio_copy_max(parameters[pos].user_data, - max, - tmpformat); - break; /* while */ - } - if (ch == SPECIFIER_USER_DEFINED_SEPARATOR) - { - without_namespace = FALSE; - /* Copy the namespace for later looking-up */ - max = (int)(&format[index] - tmpformat); - if (max > MAX_USER_NAME) - max = MAX_USER_NAME; - trio_copy_max(parameters[pos].user_name, - max, - tmpformat); - tmpformat = (char *)&format[index]; - } - } - if (ch != SPECIFIER_USER_DEFINED_END) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - break; -#endif /* defined(SPECIFIER_USER_DEFINED_BEGIN) */ - - default: - /* Bail out completely to make the error more obvious */ - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - - /* Count the number of times this entry has been used */ - usedEntries[currentParam] += 1; - - /* Find last sticky parameters */ - if (gotSticky && !(flags & FLAGS_STICKY)) - { - for (i = pos - 1; i >= 0; i--) - { - if (parameters[i].type == FORMAT_PARAMETER) - continue; - if ((parameters[i].flags & FLAGS_STICKY) && - (parameters[i].type == parameters[pos].type)) - { - /* Do not overwrite current qualifiers */ - flags |= (parameters[i].flags & (unsigned long)~FLAGS_STICKY); - if (width == NO_WIDTH) - width = parameters[i].width; - if (precision == NO_PRECISION) - precision = parameters[i].precision; - if (base == NO_BASE) - base = parameters[i].base; - break; - } - } - } - - parameters[pos].indexAfterSpecifier = index; - parameters[pos].flags = flags; - parameters[pos].width = width; - parameters[pos].precision = precision; - parameters[pos].base = (base == NO_BASE) ? BASE_DECIMAL : base; - parameters[pos].varsize = varsize; - pos++; - - if (! positional) - parameterPosition++; - - } /* if identifier */ - - } /* while format characters left */ - - for (num = 0; num <= maxParam; num++) - { - if (usedEntries[num] != 1) - { - if (usedEntries[num] == 0) /* gap detected */ - return TRIO_ERROR_RETURN(TRIO_EGAP, num); - else /* double references detected */ - return TRIO_ERROR_RETURN(TRIO_EDBLREF, num); - } - - i = indices[num]; - - /* - * FORMAT_PARAMETERS are only present if they must be read, - * so it makes no sense to check the ignore flag (besides, - * the flags variable is not set for that particular type) - */ - if ((parameters[i].type != FORMAT_PARAMETER) && - (parameters[i].flags & FLAGS_IGNORE)) - continue; /* for all arguments */ - - /* - * The stack arguments are read according to ANSI C89 - * default argument promotions: - * - * char = int - * short = int - * unsigned char = unsigned int - * unsigned short = unsigned int - * float = double - * - * In addition to the ANSI C89 these types are read (the - * default argument promotions of C99 has not been - * considered yet) - * - * long long - * long double - * size_t - * ptrdiff_t - * intmax_t - */ - switch (parameters[i].type) - { - case FORMAT_GROUP: - case FORMAT_STRING: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - parameters[i].data.wstring = (argarray == NULL) - ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_wchar_t *) - : (trio_wchar_t *)(argarray[num]); - } - else -#endif - { - parameters[i].data.string = (argarray == NULL) - ? va_arg(TRIO_VA_LIST_DEREF(arglist), char *) - : (char *)(argarray[num]); - } - break; - -#if defined(FORMAT_USER_DEFINED) - case FORMAT_USER_DEFINED: -#endif - case FORMAT_POINTER: - case FORMAT_COUNT: - case FORMAT_UNKNOWN: - parameters[i].data.pointer = (argarray == NULL) - ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_pointer_t ) - : argarray[num]; - break; - - case FORMAT_CHAR: - case FORMAT_INT: - if (TYPE_SCAN == type) - { - if (argarray == NULL) - parameters[i].data.pointer = - (trio_pointer_t)va_arg(TRIO_VA_LIST_DEREF(arglist), trio_pointer_t); - else - { - if (parameters[i].type == FORMAT_CHAR) - parameters[i].data.pointer = - (trio_pointer_t)((char *)argarray[num]); - else if (parameters[i].flags & FLAGS_SHORT) - parameters[i].data.pointer = - (trio_pointer_t)((short *)argarray[num]); - else - parameters[i].data.pointer = - (trio_pointer_t)((int *)argarray[num]); - } - } - else - { -#if defined(QUALIFIER_VARSIZE) || defined(QUALIFIER_FIXED_SIZE) - if (parameters[i].flags - & (FLAGS_VARSIZE_PARAMETER | FLAGS_FIXED_SIZE)) - { - if (parameters[i].flags & FLAGS_VARSIZE_PARAMETER) - { - /* - * Variable sizes are mapped onto the fixed sizes, in - * accordance with integer promotion. - * - * Please note that this may not be portable, as we - * only guess the size, not the layout of the numbers. - * For example, if int is little-endian, and long is - * big-endian, then this will fail. - */ - varsize = (int)parameters[parameters[i].varsize].data.number.as_unsigned; - } - else - { - /* Used for the I modifiers */ - varsize = parameters[i].varsize; - } - parameters[i].flags &= ~FLAGS_ALL_VARSIZES; - - if (varsize <= (int)sizeof(int)) - ; - else if (varsize <= (int)sizeof(long)) - parameters[i].flags |= FLAGS_LONG; -#if defined(QUALIFIER_INTMAX_T) - else if (varsize <= (int)sizeof(trio_longlong_t)) - parameters[i].flags |= FLAGS_QUAD; - else - parameters[i].flags |= FLAGS_INTMAX_T; -#else - else - parameters[i].flags |= FLAGS_QUAD; -#endif - } -#endif /* defined(QUALIFIER_VARSIZE) */ -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (parameters[i].flags & FLAGS_SIZE_T) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), size_t) - : (trio_uintmax_t)(*((size_t *)argarray[num])); - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (parameters[i].flags & FLAGS_PTRDIFF_T) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), ptrdiff_t) - : (trio_uintmax_t)(*((ptrdiff_t *)argarray[num])); - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (parameters[i].flags & FLAGS_INTMAX_T) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), trio_intmax_t) - : (trio_uintmax_t)(*((trio_intmax_t *)argarray[num])); - else -#endif - if (parameters[i].flags & FLAGS_QUAD) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), trio_ulonglong_t) - : (trio_uintmax_t)(*((trio_ulonglong_t *)argarray[num])); - else if (parameters[i].flags & FLAGS_LONG) - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), long) - : (trio_uintmax_t)(*((long *)argarray[num])); - else - { - if (argarray == NULL) - parameters[i].data.number.as_unsigned = (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), int); - else - { - if (parameters[i].type == FORMAT_CHAR) - parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((char *)argarray[num])); - else if (parameters[i].flags & FLAGS_SHORT) - parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((short *)argarray[num])); - else - parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((int *)argarray[num])); - } - } - } - break; - - case FORMAT_PARAMETER: - /* - * The parameter for the user-defined specifier is a pointer, - * whereas the rest (width, precision, base) uses an integer. - */ - if (parameters[i].flags & FLAGS_USER_DEFINED) - parameters[i].data.pointer = (argarray == NULL) - ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_pointer_t ) - : argarray[num]; - else - parameters[i].data.number.as_unsigned = (argarray == NULL) - ? (trio_uintmax_t)va_arg(TRIO_VA_LIST_DEREF(arglist), int) - : (trio_uintmax_t)(*((int *)argarray[num])); - break; - - case FORMAT_DOUBLE: - if (TYPE_SCAN == type) - { - if (parameters[i].flags & FLAGS_LONGDOUBLE) - parameters[i].data.longdoublePointer = (argarray == NULL) - ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_long_double_t *) - : (trio_long_double_t *)argarray[num]; - else - { - if (parameters[i].flags & FLAGS_LONG) - parameters[i].data.doublePointer = (argarray == NULL) - ? va_arg(TRIO_VA_LIST_DEREF(arglist), double *) - : (double *)argarray[num]; - else - parameters[i].data.doublePointer = (argarray == NULL) - ? (double *)va_arg(TRIO_VA_LIST_DEREF(arglist), float *) - : (double *)((float *)argarray[num]); - } - } - else - { - if (parameters[i].flags & FLAGS_LONGDOUBLE) - parameters[i].data.longdoubleNumber = (argarray == NULL) - ? va_arg(TRIO_VA_LIST_DEREF(arglist), trio_long_double_t) - : (trio_long_double_t)(*((trio_long_double_t *)argarray[num])); - else - { - if (argarray == NULL) - parameters[i].data.longdoubleNumber = - (trio_long_double_t)va_arg(TRIO_VA_LIST_DEREF(arglist), double); - else - { - if (parameters[i].flags & FLAGS_SHORT) - parameters[i].data.longdoubleNumber = - (trio_long_double_t)(*((float *)argarray[num])); - else - parameters[i].data.longdoubleNumber = - (trio_long_double_t)(*((double *)argarray[num])); - } - } - } - break; - -#if defined(FORMAT_ERRNO) - case FORMAT_ERRNO: - parameters[i].data.errorNumber = save_errno; - break; -#endif - - default: - break; - } - } /* for all specifiers */ - return num; -} - - -/************************************************************************* - * - * FORMATTING - * - ************************************************************************/ - - -/************************************************************************* - * TrioWriteNumber - * - * Description: - * Output a number. - * The complexity of this function is a result of the complexity - * of the dependencies of the flags. - */ -TRIO_PRIVATE void -TrioWriteNumber -TRIO_ARGS6((self, number, flags, width, precision, base), - trio_class_t *self, - trio_uintmax_t number, - trio_flags_t flags, - int width, - int precision, - int base) -{ - BOOLEAN_T isNegative; - BOOLEAN_T isNumberZero; - BOOLEAN_T isPrecisionZero; - BOOLEAN_T ignoreNumber; - char buffer[MAX_CHARS_IN(trio_uintmax_t) * (1 + MAX_LOCALE_SEPARATOR_LENGTH) + 1]; - char *bufferend; - char *pointer; - TRIO_CONST char *digits; - int i; - int length; - char *p; - int count; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - assert(((base >= MIN_BASE) && (base <= MAX_BASE)) || (base == NO_BASE)); - - digits = (flags & FLAGS_UPPER) ? internalDigitsUpper : internalDigitsLower; - if (base == NO_BASE) - base = BASE_DECIMAL; - - isNumberZero = (number == 0); - isPrecisionZero = (precision == 0); - ignoreNumber = (isNumberZero - && isPrecisionZero - && !((flags & FLAGS_ALTERNATIVE) && (base == BASE_OCTAL))); - - if (flags & FLAGS_UNSIGNED) - { - isNegative = FALSE; - flags &= ~FLAGS_SHOWSIGN; - } - else - { - isNegative = ((trio_intmax_t)number < 0); - if (isNegative) - number = -((trio_intmax_t)number); - } - - if (flags & FLAGS_QUAD) - number &= (trio_ulonglong_t)-1; - else if (flags & FLAGS_LONG) - number &= (unsigned long)-1; - else - number &= (unsigned int)-1; - - /* Build number */ - pointer = bufferend = &buffer[sizeof(buffer) - 1]; - *pointer-- = NIL; - for (i = 1; i < (int)sizeof(buffer); i++) - { - *pointer-- = digits[number % base]; - number /= base; - if (number == 0) - break; - - if ((flags & FLAGS_QUOTE) && TrioFollowedBySeparator(i + 1)) - { - /* - * We are building the number from the least significant - * to the most significant digit, so we have to copy the - * thousand separator backwards - */ - length = internalThousandSeparatorLength; - if (((int)(pointer - buffer) - length) > 0) - { - p = &internalThousandSeparator[length - 1]; - while (length-- > 0) - *pointer-- = *p--; - } - } - } - - if (! ignoreNumber) - { - /* Adjust width */ - width -= (bufferend - pointer) - 1; - } - - /* Adjust precision */ - if (NO_PRECISION != precision) - { - precision -= (bufferend - pointer) - 1; - if (precision < 0) - precision = 0; - flags |= FLAGS_NILPADDING; - } - - /* Calculate padding */ - count = (! ((flags & FLAGS_LEFTADJUST) || (precision == NO_PRECISION))) - ? precision - : 0; - - /* Adjust width further */ - if (isNegative || (flags & FLAGS_SHOWSIGN) || (flags & FLAGS_SPACE)) - width--; - if ((flags & FLAGS_ALTERNATIVE) && !isNumberZero) - { - switch (base) - { - case BASE_BINARY: - case BASE_HEX: - width -= 2; - break; - case BASE_OCTAL: - if (!(flags & FLAGS_NILPADDING) || (count == 0)) - width--; - break; - default: - break; - } - } - - /* Output prefixes spaces if needed */ - if (! ((flags & FLAGS_LEFTADJUST) || - ((flags & FLAGS_NILPADDING) && (precision == NO_PRECISION)))) - { - while (width-- > count) - self->OutStream(self, CHAR_ADJUST); - } - - /* width has been adjusted for signs and alternatives */ - if (isNegative) - self->OutStream(self, '-'); - else if (flags & FLAGS_SHOWSIGN) - self->OutStream(self, '+'); - else if (flags & FLAGS_SPACE) - self->OutStream(self, ' '); - - /* Prefix is not written when the value is zero */ - if ((flags & FLAGS_ALTERNATIVE) && !isNumberZero) - { - switch (base) - { - case BASE_BINARY: - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'B' : 'b'); - break; - - case BASE_OCTAL: - if (!(flags & FLAGS_NILPADDING) || (count == 0)) - self->OutStream(self, '0'); - break; - - case BASE_HEX: - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); - break; - - default: - break; - } /* switch base */ - } - - /* Output prefixed zero padding if needed */ - if (flags & FLAGS_NILPADDING) - { - if (precision == NO_PRECISION) - precision = width; - while (precision-- > 0) - { - self->OutStream(self, '0'); - width--; - } - } - - if (! ignoreNumber) - { - /* Output the number itself */ - while (*(++pointer)) - { - self->OutStream(self, *pointer); - } - } - - /* Output trailing spaces if needed */ - if (flags & FLAGS_LEFTADJUST) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } -} - -/************************************************************************* - * TrioWriteStringCharacter - * - * Description: - * Output a single character of a string - */ -TRIO_PRIVATE void -TrioWriteStringCharacter -TRIO_ARGS3((self, ch, flags), - trio_class_t *self, - int ch, - trio_flags_t flags) -{ - if (flags & FLAGS_ALTERNATIVE) - { - if (! isprint(ch)) - { - /* - * Non-printable characters are converted to C escapes or - * \number, if no C escape exists. - */ - self->OutStream(self, CHAR_BACKSLASH); - switch (ch) - { - case '\007': self->OutStream(self, 'a'); break; - case '\b': self->OutStream(self, 'b'); break; - case '\f': self->OutStream(self, 'f'); break; - case '\n': self->OutStream(self, 'n'); break; - case '\r': self->OutStream(self, 'r'); break; - case '\t': self->OutStream(self, 't'); break; - case '\v': self->OutStream(self, 'v'); break; - case '\\': self->OutStream(self, '\\'); break; - default: - self->OutStream(self, 'x'); - TrioWriteNumber(self, (trio_uintmax_t)ch, - FLAGS_UNSIGNED | FLAGS_NILPADDING, - 2, 2, BASE_HEX); - break; - } - } - else if (ch == CHAR_BACKSLASH) - { - self->OutStream(self, CHAR_BACKSLASH); - self->OutStream(self, CHAR_BACKSLASH); - } - else - { - self->OutStream(self, ch); - } - } - else - { - self->OutStream(self, ch); - } -} - -/************************************************************************* - * TrioWriteString - * - * Description: - * Output a string - */ -TRIO_PRIVATE void -TrioWriteString -TRIO_ARGS5((self, string, flags, width, precision), - trio_class_t *self, - TRIO_CONST char *string, - trio_flags_t flags, - int width, - int precision) -{ - int length; - int ch; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - - if (string == NULL) - { - string = internalNullString; - length = sizeof(internalNullString) - 1; - /* Disable quoting for the null pointer */ - flags &= (~FLAGS_QUOTE); - width = 0; - } - else - { - length = trio_length(string); - } - if ((NO_PRECISION != precision) && - (precision < length)) - { - length = precision; - } - width -= length; - - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); - - if (! (flags & FLAGS_LEFTADJUST)) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - - while (length-- > 0) - { - /* The ctype parameters must be an unsigned char (or EOF) */ - ch = (int)((unsigned char)(*string++)); - TrioWriteStringCharacter(self, ch, flags); - } - - if (flags & FLAGS_LEFTADJUST) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); -} - -/************************************************************************* - * TrioWriteWideStringCharacter - * - * Description: - * Output a wide string as a multi-byte sequence - */ -#if TRIO_WIDECHAR -TRIO_PRIVATE int -TrioWriteWideStringCharacter -TRIO_ARGS4((self, wch, flags, width), - trio_class_t *self, - trio_wchar_t wch, - trio_flags_t flags, - int width) -{ - int size; - int i; - int ch; - char *string; - char buffer[MB_LEN_MAX + 1]; - - if (width == NO_WIDTH) - width = sizeof(buffer); - - size = wctomb(buffer, wch); - if ((size <= 0) || (size > width) || (buffer[0] == NIL)) - return 0; - - string = buffer; - i = size; - while ((width >= i) && (width-- > 0) && (i-- > 0)) - { - /* The ctype parameters must be an unsigned char (or EOF) */ - ch = (int)((unsigned char)(*string++)); - TrioWriteStringCharacter(self, ch, flags); - } - return size; -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioWriteWideString - * - * Description: - * Output a wide character string as a multi-byte string - */ -#if TRIO_WIDECHAR -TRIO_PRIVATE void -TrioWriteWideString -TRIO_ARGS5((self, wstring, flags, width, precision), - trio_class_t *self, - TRIO_CONST trio_wchar_t *wstring, - trio_flags_t flags, - int width, - int precision) -{ - int length; - int size; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - (void)mblen(NULL, 0); -#endif - - if (wstring == NULL) - { - TrioWriteString(self, NULL, flags, width, precision); - return; - } - - if (NO_PRECISION == precision) - { - length = INT_MAX; - } - else - { - length = precision; - width -= length; - } - - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); - - if (! (flags & FLAGS_LEFTADJUST)) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - - while (length > 0) - { - size = TrioWriteWideStringCharacter(self, *wstring++, flags, length); - if (size == 0) - break; /* while */ - length -= size; - } - - if (flags & FLAGS_LEFTADJUST) - { - while (width-- > 0) - self->OutStream(self, CHAR_ADJUST); - } - if (flags & FLAGS_QUOTE) - self->OutStream(self, CHAR_QUOTE); -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioWriteDouble - * - * http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_211.htm - * - * "5.2.4.2.2 paragraph #4 - * - * The accuracy [...] is implementation defined, as is the accuracy - * of the conversion between floating-point internal representations - * and string representations performed by the library routine in - * " - */ -/* FIXME: handle all instances of constant long-double number (L) - * and *l() math functions. - */ -TRIO_PRIVATE void -TrioWriteDouble -TRIO_ARGS6((self, number, flags, width, precision, base), - trio_class_t *self, - trio_long_double_t number, - trio_flags_t flags, - int width, - int precision, - int base) -{ - trio_long_double_t integerNumber; - trio_long_double_t fractionNumber; - trio_long_double_t workNumber; - int integerDigits; - int fractionDigits; - int exponentDigits; - int baseDigits; - int integerThreshold; - int fractionThreshold; - int expectedWidth; - int exponent = 0; - unsigned int uExponent = 0; - int exponentBase; - trio_long_double_t dblBase; - trio_long_double_t dblIntegerBase; - trio_long_double_t dblFractionBase; - trio_long_double_t integerAdjust; - trio_long_double_t fractionAdjust; - BOOLEAN_T isNegative; - BOOLEAN_T isExponentNegative = FALSE; - BOOLEAN_T requireTwoDigitExponent; - BOOLEAN_T isHex; - TRIO_CONST char *digits; - char *groupingPointer; - int i; - int index; - BOOLEAN_T hasOnlyZeroes; - int zeroes = 0; - register int trailingZeroes; - BOOLEAN_T keepTrailingZeroes; - BOOLEAN_T keepDecimalPoint; - trio_long_double_t epsilon; - - assert(VALID(self)); - assert(VALID(self->OutStream)); - assert(((base >= MIN_BASE) && (base <= MAX_BASE)) || (base == NO_BASE)); - - /* Determine sign and look for special quantities */ - switch (trio_fpclassify_and_signbit(number, &isNegative)) - { - case TRIO_FP_NAN: - TrioWriteString(self, - (flags & FLAGS_UPPER) - ? NAN_UPPER - : NAN_LOWER, - flags, width, precision); - return; - - case TRIO_FP_INFINITE: - if (isNegative) - { - /* Negative infinity */ - TrioWriteString(self, - (flags & FLAGS_UPPER) - ? "-" INFINITE_UPPER - : "-" INFINITE_LOWER, - flags, width, precision); - return; - } - else - { - /* Positive infinity */ - TrioWriteString(self, - (flags & FLAGS_UPPER) - ? INFINITE_UPPER - : INFINITE_LOWER, - flags, width, precision); - return; - } - - default: - /* Finitude */ - break; - } - - /* Normal numbers */ - if (flags & FLAGS_LONGDOUBLE) - { - baseDigits = (base == 10) - ? LDBL_DIG - : (int)floor(LDBL_MANT_DIG / TrioLogarithmBase(base)); - epsilon = LDBL_EPSILON; - } - else if (flags & FLAGS_SHORT) - { - baseDigits = (base == BASE_DECIMAL) - ? FLT_DIG - : (int)floor(FLT_MANT_DIG / TrioLogarithmBase(base)); - epsilon = FLT_EPSILON; - } - else - { - baseDigits = (base == BASE_DECIMAL) - ? DBL_DIG - : (int)floor(DBL_MANT_DIG / TrioLogarithmBase(base)); - epsilon = DBL_EPSILON; - } - - digits = (flags & FLAGS_UPPER) ? internalDigitsUpper : internalDigitsLower; - isHex = (base == BASE_HEX); - if (base == NO_BASE) - base = BASE_DECIMAL; - dblBase = (trio_long_double_t)base; - keepTrailingZeroes = !( (flags & FLAGS_ROUNDING) || - ( (flags & FLAGS_FLOAT_G) && - !(flags & FLAGS_ALTERNATIVE) ) ); - - if (flags & FLAGS_ROUNDING) - precision = baseDigits; - - if (precision == NO_PRECISION) - { - if (isHex) - { - keepTrailingZeroes = FALSE; - precision = FLT_MANT_DIG; - } - else - { - precision = FLT_DIG; - } - } - - if (isNegative) - number = -number; - - if (isHex) - flags |= FLAGS_FLOAT_E; - - if (flags & FLAGS_FLOAT_G) - { - if (precision == 0) - precision = 1; - - if ((number < 1.0E-4) || (number > powl(base, - (trio_long_double_t)precision))) - { - /* Use scientific notation */ - flags |= FLAGS_FLOAT_E; - } - else if (number < 1.0) - { - /* - * Use normal notation. If the integer part of the number is - * zero, then adjust the precision to include leading fractional - * zeros. - */ - workNumber = TrioLogarithm(number, base); - workNumber = TRIO_FABS(workNumber); - if (workNumber - floorl(workNumber) < 0.001) - workNumber--; - zeroes = (int)floorl(workNumber); - } - } - - if (flags & FLAGS_FLOAT_E) - { - /* Scale the number */ - workNumber = TrioLogarithm(number, base); - if (trio_isinf(workNumber) == -1) - { - exponent = 0; - /* Undo setting */ - if (flags & FLAGS_FLOAT_G) - flags &= ~FLAGS_FLOAT_E; - } - else - { - exponent = (int)floorl(workNumber); - number /= powl(dblBase, (trio_long_double_t)exponent); - isExponentNegative = (exponent < 0); - uExponent = (isExponentNegative) ? -exponent : exponent; - if (isHex) - uExponent *= 4; /* log16(2) */ - /* No thousand separators */ - flags &= ~FLAGS_QUOTE; - } - } - - integerNumber = floorl(number); - fractionNumber = number - integerNumber; - - /* - * Truncated number. - * - * Precision is number of significant digits for FLOAT_G - * and number of fractional digits for others. - */ - integerDigits = (integerNumber > epsilon) - ? 1 + (int)TrioLogarithm(integerNumber, base) - : 1; - fractionDigits = ((flags & FLAGS_FLOAT_G) && (zeroes == 0)) - ? precision - integerDigits - : zeroes + precision; - - dblFractionBase = TrioPower(base, fractionDigits); - - workNumber = number + 0.5 / dblFractionBase; - if (floorl(number) != floorl(workNumber)) - { - if (flags & FLAGS_FLOAT_E) - { - /* Adjust if number was rounded up one digit (ie. 0.99 to 1.00) */ - exponent++; - isExponentNegative = (exponent < 0); - uExponent = (isExponentNegative) ? -exponent : exponent; - if (isHex) - uExponent *= 4; /* log16(2) */ - workNumber = (number + 0.5 / dblFractionBase) / dblBase; - integerNumber = floorl(workNumber); - fractionNumber = workNumber - integerNumber; - } - else - { - /* Adjust if number was rounded up one digit (ie. 99 to 100) */ - integerNumber = floorl(number + 0.5); - fractionNumber = 0.0; - integerDigits = (integerNumber > epsilon) - ? 1 + (int)TrioLogarithm(integerNumber, base) - : 1; - } - } - - /* Estimate accuracy */ - integerAdjust = fractionAdjust = 0.5; - if (flags & FLAGS_ROUNDING) - { - if (integerDigits > baseDigits) - { - integerThreshold = baseDigits; - fractionDigits = 0; - dblFractionBase = 1.0; - fractionThreshold = 0; - precision = 0; /* Disable decimal-point */ - integerAdjust = TrioPower(base, integerDigits - integerThreshold - 1); - fractionAdjust = 0.0; - } - else - { - integerThreshold = integerDigits; - fractionThreshold = fractionDigits - integerThreshold; - fractionAdjust = 1.0; - } - } - else - { - integerThreshold = INT_MAX; - fractionThreshold = INT_MAX; - } - - /* - * Calculate expected width. - * sign + integer part + thousands separators + decimal point - * + fraction + exponent - */ - fractionAdjust /= dblFractionBase; - hasOnlyZeroes = (floorl((fractionNumber + fractionAdjust) * dblFractionBase) < epsilon); - keepDecimalPoint = ( (flags & FLAGS_ALTERNATIVE) || - !((precision == 0) || - (!keepTrailingZeroes && hasOnlyZeroes)) ); - if (flags & FLAGS_FLOAT_E) - { - exponentDigits = (uExponent == 0) - ? 1 - : (int)ceil(TrioLogarithm((double)(uExponent + 1), - (isHex) ? 10.0 : base)); - } - else - exponentDigits = 0; - requireTwoDigitExponent = ((base == BASE_DECIMAL) && (exponentDigits == 1)); - - expectedWidth = integerDigits + fractionDigits - + (keepDecimalPoint - ? internalDecimalPointLength - : 0) - + ((flags & FLAGS_QUOTE) - ? TrioCalcThousandSeparatorLength(integerDigits) - : 0); - if (isNegative || (flags & FLAGS_SHOWSIGN) || (flags & FLAGS_SPACE)) - expectedWidth += sizeof("-") - 1; - if (exponentDigits > 0) - expectedWidth += exponentDigits + - ((requireTwoDigitExponent ? sizeof("E+0") : sizeof("E+")) - 1); - if (isHex) - expectedWidth += sizeof("0X") - 1; - - /* Output prefixing */ - if (flags & FLAGS_NILPADDING) - { - /* Leading zeros must be after sign */ - if (isNegative) - self->OutStream(self, '-'); - else if (flags & FLAGS_SHOWSIGN) - self->OutStream(self, '+'); - else if (flags & FLAGS_SPACE) - self->OutStream(self, ' '); - if (isHex) - { - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); - } - if (!(flags & FLAGS_LEFTADJUST)) - { - for (i = expectedWidth; i < width; i++) - { - self->OutStream(self, '0'); - } - } - } - else - { - /* Leading spaces must be before sign */ - if (!(flags & FLAGS_LEFTADJUST)) - { - for (i = expectedWidth; i < width; i++) - { - self->OutStream(self, CHAR_ADJUST); - } - } - if (isNegative) - self->OutStream(self, '-'); - else if (flags & FLAGS_SHOWSIGN) - self->OutStream(self, '+'); - else if (flags & FLAGS_SPACE) - self->OutStream(self, ' '); - if (isHex) - { - self->OutStream(self, '0'); - self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); - } - } - - /* Output the integer part and thousand separators */ - dblIntegerBase = 1.0 / TrioPower(base, integerDigits - 1); - for (i = 0; i < integerDigits; i++) - { - workNumber = floorl(((integerNumber + integerAdjust) * dblIntegerBase)); - if (i > integerThreshold) - { - /* Beyond accuracy */ - self->OutStream(self, digits[0]); - } - else - { - self->OutStream(self, digits[(int)fmodl(workNumber, dblBase)]); - } - dblIntegerBase *= dblBase; - - if (((flags & (FLAGS_FLOAT_E | FLAGS_QUOTE)) == FLAGS_QUOTE) - && TrioFollowedBySeparator(integerDigits - i)) - { - for (groupingPointer = internalThousandSeparator; - *groupingPointer != NIL; - groupingPointer++) - { - self->OutStream(self, *groupingPointer); - } - } - } - - /* Insert decimal point and build the fraction part */ - trailingZeroes = 0; - - if (keepDecimalPoint) - { - if (internalDecimalPoint) - { - self->OutStream(self, internalDecimalPoint); - } - else - { - for (i = 0; i < internalDecimalPointLength; i++) - { - self->OutStream(self, internalDecimalPointString[i]); - } - } - } - - for (i = 0; i < fractionDigits; i++) - { - if ((integerDigits > integerThreshold) || (i > fractionThreshold)) - { - /* Beyond accuracy */ - trailingZeroes++; - } - else - { - fractionNumber *= dblBase; - fractionAdjust *= dblBase; - workNumber = floorl(fractionNumber + fractionAdjust); - fractionNumber -= workNumber; - index = (int)fmodl(workNumber, dblBase); - if (index == 0) - { - trailingZeroes++; - } - else - { - while (trailingZeroes > 0) - { - /* Not trailing zeroes after all */ - self->OutStream(self, digits[0]); - trailingZeroes--; - } - self->OutStream(self, digits[index]); - } - } - } - - if (keepTrailingZeroes) - { - while (trailingZeroes > 0) - { - self->OutStream(self, digits[0]); - trailingZeroes--; - } - } - - /* Output exponent */ - if (exponentDigits > 0) - { - self->OutStream(self, - isHex - ? ((flags & FLAGS_UPPER) ? 'P' : 'p') - : ((flags & FLAGS_UPPER) ? 'E' : 'e')); - self->OutStream(self, (isExponentNegative) ? '-' : '+'); - - /* The exponent must contain at least two digits */ - if (requireTwoDigitExponent) - self->OutStream(self, '0'); - - if (isHex) - base = 10.0; - exponentBase = (int)TrioPower(base, exponentDigits - 1); - for (i = 0; i < exponentDigits; i++) - { - self->OutStream(self, digits[(uExponent / exponentBase) % base]); - exponentBase /= base; - } - } - /* Output trailing spaces */ - if (flags & FLAGS_LEFTADJUST) - { - for (i = expectedWidth; i < width; i++) - { - self->OutStream(self, CHAR_ADJUST); - } - } -} - -/************************************************************************* - * TrioFormatProcess - * - * Description: - * This is the main engine for formatting output - */ -TRIO_PRIVATE int -TrioFormatProcess -TRIO_ARGS3((data, format, parameters), - trio_class_t *data, - TRIO_CONST char *format, - trio_parameter_t *parameters) -{ -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - int charlen; -#endif - int i; - TRIO_CONST char *string; - trio_pointer_t pointer; - trio_flags_t flags; - int width; - int precision; - int base; - int index; - - index = 0; - i = 0; -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - (void)mblen(NULL, 0); -#endif - - while (format[index]) - { -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - if (! isascii(format[index])) - { - charlen = mblen(&format[index], MB_LEN_MAX); - /* - * Only valid multibyte characters are handled here. Invalid - * multibyte characters (charlen == -1) are handled as normal - * characters. - */ - if (charlen != -1) - { - while (charlen-- > 0) - { - data->OutStream(data, format[index++]); - } - continue; /* while characters left in formatting string */ - } - } -#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ - if (CHAR_IDENTIFIER == format[index]) - { - if (CHAR_IDENTIFIER == format[index + 1]) - { - data->OutStream(data, CHAR_IDENTIFIER); - index += 2; - } - else - { - /* Skip the parameter entries */ - while (parameters[i].type == FORMAT_PARAMETER) - i++; - - flags = parameters[i].flags; - - /* Find width */ - width = parameters[i].width; - if (flags & FLAGS_WIDTH_PARAMETER) - { - /* Get width from parameter list */ - width = (int)parameters[width].data.number.as_signed; - if (width < 0) - { - /* - * A negative width is the same as the - flag and - * a positive width. - */ - flags |= FLAGS_LEFTADJUST; - flags &= ~FLAGS_NILPADDING; - width = -width; - } - } - - /* Find precision */ - if (flags & FLAGS_PRECISION) - { - precision = parameters[i].precision; - if (flags & FLAGS_PRECISION_PARAMETER) - { - /* Get precision from parameter list */ - precision = (int)parameters[precision].data.number.as_signed; - if (precision < 0) - { - /* - * A negative precision is the same as no - * precision - */ - precision = NO_PRECISION; - } - } - } - else - { - precision = NO_PRECISION; - } - - /* Find base */ - base = parameters[i].base; - if (flags & FLAGS_BASE_PARAMETER) - { - /* Get base from parameter list */ - base = (int)parameters[base].data.number.as_signed; - } - - switch (parameters[i].type) - { - case FORMAT_CHAR: - if (flags & FLAGS_QUOTE) - data->OutStream(data, CHAR_QUOTE); - if (! (flags & FLAGS_LEFTADJUST)) - { - while (--width > 0) - data->OutStream(data, CHAR_ADJUST); - } -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - TrioWriteWideStringCharacter(data, - (trio_wchar_t)parameters[i].data.number.as_signed, - flags, - NO_WIDTH); - } - else -#endif - { - TrioWriteStringCharacter(data, - (int)parameters[i].data.number.as_signed, - flags); - } - - if (flags & FLAGS_LEFTADJUST) - { - while(--width > 0) - data->OutStream(data, CHAR_ADJUST); - } - if (flags & FLAGS_QUOTE) - data->OutStream(data, CHAR_QUOTE); - - break; /* FORMAT_CHAR */ - - case FORMAT_INT: - TrioWriteNumber(data, - parameters[i].data.number.as_unsigned, - flags, - width, - precision, - base); - - break; /* FORMAT_INT */ - - case FORMAT_DOUBLE: - TrioWriteDouble(data, - parameters[i].data.longdoubleNumber, - flags, - width, - precision, - base); - break; /* FORMAT_DOUBLE */ - - case FORMAT_STRING: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - TrioWriteWideString(data, - parameters[i].data.wstring, - flags, - width, - precision); - } - else -#endif - { - TrioWriteString(data, - parameters[i].data.string, - flags, - width, - precision); - } - break; /* FORMAT_STRING */ - - case FORMAT_POINTER: - { - trio_reference_t reference; - - reference.data = data; - reference.parameter = ¶meters[i]; - trio_print_pointer(&reference, parameters[i].data.pointer); - } - break; /* FORMAT_POINTER */ - - case FORMAT_COUNT: - pointer = parameters[i].data.pointer; - if (NULL != pointer) - { - /* - * C99 paragraph 7.19.6.1.8 says "the number of - * characters written to the output stream so far by - * this call", which is data->committed - */ -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (flags & FLAGS_SIZE_T) - *(size_t *)pointer = (size_t)data->committed; - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (flags & FLAGS_PTRDIFF_T) - *(ptrdiff_t *)pointer = (ptrdiff_t)data->committed; - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (flags & FLAGS_INTMAX_T) - *(trio_intmax_t *)pointer = (trio_intmax_t)data->committed; - else -#endif - if (flags & FLAGS_QUAD) - { - *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)data->committed; - } - else if (flags & FLAGS_LONG) - { - *(long int *)pointer = (long int)data->committed; - } - else if (flags & FLAGS_SHORT) - { - *(short int *)pointer = (short int)data->committed; - } - else - { - *(int *)pointer = (int)data->committed; - } - } - break; /* FORMAT_COUNT */ - - case FORMAT_PARAMETER: - break; /* FORMAT_PARAMETER */ - -#if defined(FORMAT_ERRNO) - case FORMAT_ERRNO: - string = trio_error(parameters[i].data.errorNumber); - if (string) - { - TrioWriteString(data, - string, - flags, - width, - precision); - } - else - { - data->OutStream(data, '#'); - TrioWriteNumber(data, - (trio_uintmax_t)parameters[i].data.errorNumber, - flags, - width, - precision, - BASE_DECIMAL); - } - break; /* FORMAT_ERRNO */ -#endif /* defined(FORMAT_ERRNO) */ - -#if defined(FORMAT_USER_DEFINED) - case FORMAT_USER_DEFINED: - { - trio_reference_t reference; - trio_userdef_t *def = NULL; - - if (parameters[i].user_name[0] == NIL) - { - /* Use handle */ - if ((i > 0) || - (parameters[i - 1].type == FORMAT_PARAMETER)) - def = (trio_userdef_t *)parameters[i - 1].data.pointer; - } - else - { - /* Look up namespace */ - def = TrioFindNamespace(parameters[i].user_name, NULL); - } - if (def) { - reference.data = data; - reference.parameter = ¶meters[i]; - def->callback(&reference); - } - } - break; -#endif /* defined(FORMAT_USER_DEFINED) */ - - default: - break; - } /* switch parameter type */ - - /* Prepare for next */ - index = parameters[i].indexAfterSpecifier; - i++; - } - } - else /* not identifier */ - { - data->OutStream(data, format[index++]); - } - } - return data->processed; -} - -/************************************************************************* - * TrioFormatRef - */ -TRIO_PRIVATE int -TrioFormatRef -TRIO_ARGS4((reference, format, arglist, argarray), - trio_reference_t *reference, - TRIO_CONST char *format, - TRIO_VA_LIST_PTR arglist, - trio_pointer_t *argarray) -{ - int status; - trio_parameter_t parameters[MAX_PARAMETERS]; - - status = TrioParse(TYPE_PRINT, format, parameters, arglist, argarray); - if (status < 0) - return status; - - status = TrioFormatProcess(reference->data, format, parameters); - if (reference->data->error != 0) - { - status = reference->data->error; - } - return status; -} - -/************************************************************************* - * TrioFormat - */ -TRIO_PRIVATE int -TrioFormat -TRIO_ARGS6((destination, destinationSize, OutStream, format, arglist, argarray), - trio_pointer_t destination, - size_t destinationSize, - void (*OutStream) TRIO_PROTO((trio_class_t *, int)), - TRIO_CONST char *format, - TRIO_VA_LIST_PTR arglist, - trio_pointer_t *argarray) -{ - int status; - trio_class_t data; - trio_parameter_t parameters[MAX_PARAMETERS]; - - assert(VALID(OutStream)); - assert(VALID(format)); - - memset(&data, 0, sizeof(data)); - data.OutStream = OutStream; - data.location = destination; - data.max = destinationSize; - data.error = 0; - -#if defined(USE_LOCALE) - if (NULL == internalLocaleValues) - { - TrioSetLocale(); - } -#endif - - status = TrioParse(TYPE_PRINT, format, parameters, arglist, argarray); - if (status < 0) - return status; - - status = TrioFormatProcess(&data, format, parameters); - if (data.error != 0) - { - status = data.error; - } - return status; -} - -/************************************************************************* - * TrioOutStreamFile - */ -TRIO_PRIVATE void -TrioOutStreamFile -TRIO_ARGS2((self, output), - trio_class_t *self, - int output) -{ - FILE *file; - - assert(VALID(self)); - assert(VALID(self->location)); - - file = (FILE *)self->location; - self->processed++; - if (fputc(output, file) == EOF) - { - self->error = TRIO_ERROR_RETURN(TRIO_EOF, 0); - } - else - { - self->committed++; - } -} - -/************************************************************************* - * TrioOutStreamFileDescriptor - */ -TRIO_PRIVATE void -TrioOutStreamFileDescriptor -TRIO_ARGS2((self, output), - trio_class_t *self, - int output) -{ - int fd; - char ch; - - assert(VALID(self)); - - fd = *((int *)self->location); - ch = (char)output; - self->processed++; - if (write(fd, &ch, sizeof(char)) == -1) - { - self->error = TRIO_ERROR_RETURN(TRIO_ERRNO, 0); - } - else - { - self->committed++; - } -} - -/************************************************************************* - * TrioOutStreamCustom - */ -TRIO_PRIVATE void -TrioOutStreamCustom -TRIO_ARGS2((self, output), - trio_class_t *self, - int output) -{ - int status; - trio_custom_t *data; - - assert(VALID(self)); - assert(VALID(self->location)); - - data = (trio_custom_t *)self->location; - if (data->stream.out) - { - status = (data->stream.out)(data->closure, output); - if (status >= 0) - { - self->committed++; - } - else - { - if (self->error == 0) - { - self->error = TRIO_ERROR_RETURN(TRIO_ECUSTOM, -status); - } - } - } - self->processed++; -} - -/************************************************************************* - * TrioOutStreamString - */ -TRIO_PRIVATE void -TrioOutStreamString -TRIO_ARGS2((self, output), - trio_class_t *self, - int output) -{ - char **buffer; - - assert(VALID(self)); - assert(VALID(self->location)); - - buffer = (char **)self->location; - **buffer = (char)output; - (*buffer)++; - self->processed++; - self->committed++; -} - -/************************************************************************* - * TrioOutStreamStringMax - */ -TRIO_PRIVATE void -TrioOutStreamStringMax -TRIO_ARGS2((self, output), - trio_class_t *self, - int output) -{ - char **buffer; - - assert(VALID(self)); - assert(VALID(self->location)); - - buffer = (char **)self->location; - - if (self->processed < self->max) - { - **buffer = (char)output; - (*buffer)++; - self->committed++; - } - self->processed++; -} - -/************************************************************************* - * TrioOutStreamStringDynamic - */ -TRIO_PRIVATE void -TrioOutStreamStringDynamic -TRIO_ARGS2((self, output), - trio_class_t *self, - int output) -{ - assert(VALID(self)); - assert(VALID(self->location)); - - if (self->error == 0) - { - trio_xstring_append_char((trio_string_t *)self->location, - (char)output); - self->committed++; - } - /* The processed variable must always be increased */ - self->processed++; -} - -/************************************************************************* - * - * Formatted printing functions - * - ************************************************************************/ - -#if defined(TRIO_DOCUMENTATION) -# include "doc/doc_printf.h" -#endif -/** @addtogroup Printf - @{ -*/ - -/************************************************************************* - * printf - */ - -/** - Print to standard output stream. - - @param format Formatting string. - @param ... Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_printf -TRIO_VARGS2((format, va_alist), - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioFormat(stdout, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -/** - Print to standard output stream. - - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_vprintf -TRIO_ARGS2((format, args), - TRIO_CONST char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioFormat(stdout, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL); -} - -/** - Print to standard output stream. - - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_printfv -TRIO_ARGS2((format, args), - TRIO_CONST char *format, - trio_pointer_t * args) -{ - assert(VALID(format)); - - return TrioFormat(stdout, 0, TrioOutStreamFile, format, NULL, args); -} - -/************************************************************************* - * fprintf - */ - -/** - Print to file. - - @param file File pointer. - @param format Formatting string. - @param ... Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_fprintf -TRIO_VARGS3((file, format, va_alist), - FILE *file, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(file)); - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioFormat(file, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -/** - Print to file. - - @param file File pointer. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_vfprintf -TRIO_ARGS3((file, format, args), - FILE *file, - TRIO_CONST char *format, - va_list args) -{ - assert(VALID(file)); - assert(VALID(format)); - - return TrioFormat(file, 0, TrioOutStreamFile, format, TRIO_VA_LIST_ADDR(args), NULL); -} - -/** - Print to file. - - @param file File pointer. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_fprintfv -TRIO_ARGS3((file, format, args), - FILE *file, - TRIO_CONST char *format, - trio_pointer_t * args) -{ - assert(VALID(file)); - assert(VALID(format)); - - return TrioFormat(file, 0, TrioOutStreamFile, format, NULL, args); -} - -/************************************************************************* - * dprintf - */ - -/** - Print to file descriptor. - - @param fd File descriptor. - @param format Formatting string. - @param ... Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_dprintf -TRIO_VARGS3((fd, format, va_alist), - int fd, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -/** - Print to file descriptor. - - @param fd File descriptor. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_vdprintf -TRIO_ARGS3((fd, format, args), - int fd, - TRIO_CONST char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, TRIO_VA_LIST_ADDR(args), NULL); -} - -/** - Print to file descriptor. - - @param fd File descriptor. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_dprintfv -TRIO_ARGS3((fd, format, args), - int fd, - TRIO_CONST char *format, - trio_pointer_t *args) -{ - assert(VALID(format)); - - return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, NULL, args); -} - -/************************************************************************* - * cprintf - */ -TRIO_PUBLIC int -trio_cprintf -TRIO_VARGS4((stream, closure, format, va_alist), - trio_outstream_t stream, - trio_pointer_t closure, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - trio_custom_t data; - - assert(VALID(stream)); - assert(VALID(format)); - - TRIO_VA_START(args, format); - data.stream.out = stream; - data.closure = closure; - status = TrioFormat(&data, 0, TrioOutStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -TRIO_PUBLIC int -trio_vcprintf -TRIO_ARGS4((stream, closure, format, args), - trio_outstream_t stream, - trio_pointer_t closure, - TRIO_CONST char *format, - va_list args) -{ - trio_custom_t data; - - assert(VALID(stream)); - assert(VALID(format)); - - data.stream.out = stream; - data.closure = closure; - return TrioFormat(&data, 0, TrioOutStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL); -} - -TRIO_PUBLIC int -trio_cprintfv -TRIO_ARGS4((stream, closure, format, args), - trio_outstream_t stream, - trio_pointer_t closure, - TRIO_CONST char *format, - void **args) -{ - trio_custom_t data; - - assert(VALID(stream)); - assert(VALID(format)); - - data.stream.out = stream; - data.closure = closure; - return TrioFormat(&data, 0, TrioOutStreamCustom, format, NULL, args); -} - -/************************************************************************* - * sprintf - */ - -/** - Print to string. - - @param buffer Output string. - @param format Formatting string. - @param ... Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_sprintf -TRIO_VARGS3((buffer, format, va_alist), - char *buffer, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(buffer)); - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioFormat(&buffer, 0, TrioOutStreamString, format, TRIO_VA_LIST_ADDR(args), NULL); - *buffer = NIL; /* Terminate with NIL character */ - TRIO_VA_END(args); - return status; -} - -/** - Print to string. - - @param buffer Output string. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_vsprintf -TRIO_ARGS3((buffer, format, args), - char *buffer, - TRIO_CONST char *format, - va_list args) -{ - int status; - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, 0, TrioOutStreamString, format, TRIO_VA_LIST_ADDR(args), NULL); - *buffer = NIL; - return status; -} - -/** - Print to string. - - @param buffer Output string. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_sprintfv -TRIO_ARGS3((buffer, format, args), - char *buffer, - TRIO_CONST char *format, - trio_pointer_t *args) -{ - int status; - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, 0, TrioOutStreamString, format, NULL, args); - *buffer = NIL; - return status; -} - -/************************************************************************* - * snprintf - */ - -/** - Print at most @p max characters to string. - - @param buffer Output string. - @param max Maximum number of characters to print. - @param format Formatting string. - @param ... Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_snprintf -TRIO_VARGS4((buffer, max, format, va_alist), - char *buffer, - size_t max, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(buffer)); - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioFormat(&buffer, max > 0 ? max - 1 : 0, - TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL); - if (max > 0) - *buffer = NIL; - TRIO_VA_END(args); - return status; -} - -/** - Print at most @p max characters to string. - - @param buffer Output string. - @param max Maximum number of characters to print. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_vsnprintf -TRIO_ARGS4((buffer, max, format, args), - char *buffer, - size_t max, - TRIO_CONST char *format, - va_list args) -{ - int status; - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, max > 0 ? max - 1 : 0, - TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL); - if (max > 0) - *buffer = NIL; - return status; -} - -/** - Print at most @p max characters to string. - - @param buffer Output string. - @param max Maximum number of characters to print. - @param format Formatting string. - @param args Arguments. - @return Number of printed characters. - */ -TRIO_PUBLIC int -trio_snprintfv -TRIO_ARGS4((buffer, max, format, args), - char *buffer, - size_t max, - TRIO_CONST char *format, - trio_pointer_t *args) -{ - int status; - - assert(VALID(buffer)); - assert(VALID(format)); - - status = TrioFormat(&buffer, max > 0 ? max - 1 : 0, - TrioOutStreamStringMax, format, NULL, args); - if (max > 0) - *buffer = NIL; - return status; -} - -/************************************************************************* - * snprintfcat - * Appends the new string to the buffer string overwriting the '\0' - * character at the end of buffer. - */ -TRIO_PUBLIC int -trio_snprintfcat -TRIO_VARGS4((buffer, max, format, va_alist), - char *buffer, - size_t max, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - size_t buf_len; - - TRIO_VA_START(args, format); - - assert(VALID(buffer)); - assert(VALID(format)); - - buf_len = trio_length(buffer); - buffer = &buffer[buf_len]; - - status = TrioFormat(&buffer, max - 1 - buf_len, - TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - *buffer = NIL; - return status; -} - -TRIO_PUBLIC int -trio_vsnprintfcat -TRIO_ARGS4((buffer, max, format, args), - char *buffer, - size_t max, - TRIO_CONST char *format, - va_list args) -{ - int status; - size_t buf_len; - - assert(VALID(buffer)); - assert(VALID(format)); - - buf_len = trio_length(buffer); - buffer = &buffer[buf_len]; - status = TrioFormat(&buffer, max - 1 - buf_len, - TrioOutStreamStringMax, format, TRIO_VA_LIST_ADDR(args), NULL); - *buffer = NIL; - return status; -} - -/************************************************************************* - * trio_aprintf - */ - -/* Deprecated */ -TRIO_PUBLIC char * -trio_aprintf -TRIO_VARGS2((format, va_alist), - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - va_list args; - trio_string_t *info; - char *result = NULL; - - assert(VALID(format)); - - info = trio_xstring_duplicate(""); - if (info) - { - TRIO_VA_START(args, format); - (void)TrioFormat(info, 0, TrioOutStreamStringDynamic, - format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - - trio_string_terminate(info); - result = trio_string_extract(info); - trio_string_destroy(info); - } - return result; -} - -/* Deprecated */ -TRIO_PUBLIC char * -trio_vaprintf -TRIO_ARGS2((format, args), - TRIO_CONST char *format, - va_list args) -{ - trio_string_t *info; - char *result = NULL; - - assert(VALID(format)); - - info = trio_xstring_duplicate(""); - if (info) - { - (void)TrioFormat(info, 0, TrioOutStreamStringDynamic, - format, TRIO_VA_LIST_ADDR(args), NULL); - trio_string_terminate(info); - result = trio_string_extract(info); - trio_string_destroy(info); - } - return result; -} - -TRIO_PUBLIC int -trio_asprintf -TRIO_VARGS3((result, format, va_alist), - char **result, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - va_list args; - int status; - trio_string_t *info; - - assert(VALID(format)); - - *result = NULL; - - info = trio_xstring_duplicate(""); - if (info == NULL) - { - status = TRIO_ERROR_RETURN(TRIO_ENOMEM, 0); - } - else - { - TRIO_VA_START(args, format); - status = TrioFormat(info, 0, TrioOutStreamStringDynamic, - format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - if (status >= 0) - { - trio_string_terminate(info); - *result = trio_string_extract(info); - } - trio_string_destroy(info); - } - return status; -} - -TRIO_PUBLIC int -trio_vasprintf -TRIO_ARGS3((result, format, args), - char **result, - TRIO_CONST char *format, - va_list args) -{ - int status; - trio_string_t *info; - - assert(VALID(format)); - - *result = NULL; - - info = trio_xstring_duplicate(""); - if (info == NULL) - { - status = TRIO_ERROR_RETURN(TRIO_ENOMEM, 0); - } - else - { - status = TrioFormat(info, 0, TrioOutStreamStringDynamic, - format, TRIO_VA_LIST_ADDR(args), NULL); - if (status >= 0) - { - trio_string_terminate(info); - *result = trio_string_extract(info); - } - trio_string_destroy(info); - } - return status; -} - -/** @} End of Printf documentation module */ - -/************************************************************************* - * - * CALLBACK - * - ************************************************************************/ - -#if defined(TRIO_DOCUMENTATION) -# include "doc/doc_register.h" -#endif -/** - @addtogroup UserDefined - @{ -*/ - -#if TRIO_EXTENSION - -/************************************************************************* - * trio_register - */ - -/** - Register new user-defined specifier. - - @param callback - @param name - @return Handle. - */ -TRIO_PUBLIC trio_pointer_t -trio_register -TRIO_ARGS2((callback, name), - trio_callback_t callback, - TRIO_CONST char *name) -{ - trio_userdef_t *def; - trio_userdef_t *prev = NULL; - - if (callback == NULL) - return NULL; - - if (name) - { - /* Handle built-in namespaces */ - if (name[0] == ':') - { - if (trio_equal(name, ":enter")) - { - internalEnterCriticalRegion = callback; - } - else if (trio_equal(name, ":leave")) - { - internalLeaveCriticalRegion = callback; - } - return NULL; - } - - /* Bail out if namespace is too long */ - if (trio_length(name) >= MAX_USER_NAME) - return NULL; - - /* Bail out if namespace already is registered */ - def = TrioFindNamespace(name, &prev); - if (def) - return NULL; - } - - def = (trio_userdef_t *)TRIO_MALLOC(sizeof(trio_userdef_t)); - if (def) - { - if (internalEnterCriticalRegion) - (void)internalEnterCriticalRegion(NULL); - - if (name) - { - /* Link into internal list */ - if (prev == NULL) - internalUserDef = def; - else - prev->next = def; - } - /* Initialize */ - def->callback = callback; - def->name = (name == NULL) - ? NULL - : trio_duplicate(name); - def->next = NULL; - - if (internalLeaveCriticalRegion) - (void)internalLeaveCriticalRegion(NULL); - } - return (trio_pointer_t)def; -} - -/** - Unregister an existing user-defined specifier. - - @param handle - */ -void -trio_unregister -TRIO_ARGS1((handle), - trio_pointer_t handle) -{ - trio_userdef_t *self = (trio_userdef_t *)handle; - trio_userdef_t *def; - trio_userdef_t *prev = NULL; - - assert(VALID(self)); - - if (self->name) - { - def = TrioFindNamespace(self->name, &prev); - if (def) - { - if (internalEnterCriticalRegion) - (void)internalEnterCriticalRegion(NULL); - - if (prev == NULL) - internalUserDef = NULL; - else - prev->next = def->next; - - if (internalLeaveCriticalRegion) - (void)internalLeaveCriticalRegion(NULL); - } - trio_destroy(self->name); - } - TRIO_FREE(self); -} - -/************************************************************************* - * trio_get_format [public] - */ -TRIO_CONST char * -trio_get_format -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ -#if defined(FORMAT_USER_DEFINED) - assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); -#endif - - return (((trio_reference_t *)ref)->parameter->user_data); -} - -/************************************************************************* - * trio_get_argument [public] - */ -trio_pointer_t -trio_get_argument -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ -#if defined(FORMAT_USER_DEFINED) - assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); -#endif - - return ((trio_reference_t *)ref)->parameter->data.pointer; -} - -/************************************************************************* - * trio_get_width / trio_set_width [public] - */ -int -trio_get_width -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return ((trio_reference_t *)ref)->parameter->width; -} - -void -trio_set_width -TRIO_ARGS2((ref, width), - trio_pointer_t ref, - int width) -{ - ((trio_reference_t *)ref)->parameter->width = width; -} - -/************************************************************************* - * trio_get_precision / trio_set_precision [public] - */ -int -trio_get_precision -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->precision); -} - -void -trio_set_precision -TRIO_ARGS2((ref, precision), - trio_pointer_t ref, - int precision) -{ - ((trio_reference_t *)ref)->parameter->precision = precision; -} - -/************************************************************************* - * trio_get_base / trio_set_base [public] - */ -int -trio_get_base -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->base); -} - -void -trio_set_base -TRIO_ARGS2((ref, base), - trio_pointer_t ref, - int base) -{ - ((trio_reference_t *)ref)->parameter->base = base; -} - -/************************************************************************* - * trio_get_long / trio_set_long [public] - */ -int -trio_get_long -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_LONG) - ? TRUE - : FALSE; -} - -void -trio_set_long -TRIO_ARGS2((ref, is_long), - trio_pointer_t ref, - int is_long) -{ - if (is_long) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_LONG; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_LONG; -} - -/************************************************************************* - * trio_get_longlong / trio_set_longlong [public] - */ -int -trio_get_longlong -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_QUAD) - ? TRUE - : FALSE; -} - -void -trio_set_longlong -TRIO_ARGS2((ref, is_longlong), - trio_pointer_t ref, - int is_longlong) -{ - if (is_longlong) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_QUAD; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_QUAD; -} - -/************************************************************************* - * trio_get_longdouble / trio_set_longdouble [public] - */ -int -trio_get_longdouble -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_LONGDOUBLE) - ? TRUE - : FALSE; -} - -void -trio_set_longdouble -TRIO_ARGS2((ref, is_longdouble), - trio_pointer_t ref, - int is_longdouble) -{ - if (is_longdouble) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_LONGDOUBLE; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_LONGDOUBLE; -} - -/************************************************************************* - * trio_get_short / trio_set_short [public] - */ -int -trio_get_short -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SHORT) - ? TRUE - : FALSE; -} - -void -trio_set_short -TRIO_ARGS2((ref, is_short), - trio_pointer_t ref, - int is_short) -{ - if (is_short) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SHORT; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SHORT; -} - -/************************************************************************* - * trio_get_shortshort / trio_set_shortshort [public] - */ -int -trio_get_shortshort -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SHORTSHORT) - ? TRUE - : FALSE; -} - -void -trio_set_shortshort -TRIO_ARGS2((ref, is_shortshort), - trio_pointer_t ref, - int is_shortshort) -{ - if (is_shortshort) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SHORTSHORT; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SHORTSHORT; -} - -/************************************************************************* - * trio_get_alternative / trio_set_alternative [public] - */ -int -trio_get_alternative -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_ALTERNATIVE) - ? TRUE - : FALSE; -} - -void -trio_set_alternative -TRIO_ARGS2((ref, is_alternative), - trio_pointer_t ref, - int is_alternative) -{ - if (is_alternative) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_ALTERNATIVE; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_ALTERNATIVE; -} - -/************************************************************************* - * trio_get_alignment / trio_set_alignment [public] - */ -int -trio_get_alignment -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_LEFTADJUST) - ? TRUE - : FALSE; -} - -void -trio_set_alignment -TRIO_ARGS2((ref, is_leftaligned), - trio_pointer_t ref, - int is_leftaligned) -{ - if (is_leftaligned) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_LEFTADJUST; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_LEFTADJUST; -} - -/************************************************************************* - * trio_get_spacing /trio_set_spacing [public] - */ -int -trio_get_spacing -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SPACE) - ? TRUE - : FALSE; -} - -void -trio_set_spacing -TRIO_ARGS2((ref, is_space), - trio_pointer_t ref, - int is_space) -{ - if (is_space) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SPACE; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SPACE; -} - -/************************************************************************* - * trio_get_sign / trio_set_sign [public] - */ -int -trio_get_sign -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SHOWSIGN) - ? TRUE - : FALSE; -} - -void -trio_set_sign -TRIO_ARGS2((ref, is_sign), - trio_pointer_t ref, - int is_sign) -{ - if (is_sign) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SHOWSIGN; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SHOWSIGN; -} - -/************************************************************************* - * trio_get_padding / trio_set_padding [public] - */ -int -trio_get_padding -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_NILPADDING) - ? TRUE - : FALSE; -} - -void -trio_set_padding -TRIO_ARGS2((ref, is_padding), - trio_pointer_t ref, - int is_padding) -{ - if (is_padding) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_NILPADDING; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_NILPADDING; -} - -/************************************************************************* - * trio_get_quote / trio_set_quote [public] - */ -int -trio_get_quote -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_QUOTE) - ? TRUE - : FALSE; -} - -void -trio_set_quote -TRIO_ARGS2((ref, is_quote), - trio_pointer_t ref, - int is_quote) -{ - if (is_quote) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_QUOTE; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_QUOTE; -} - -/************************************************************************* - * trio_get_upper / trio_set_upper [public] - */ -int -trio_get_upper -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_UPPER) - ? TRUE - : FALSE; -} - -void -trio_set_upper -TRIO_ARGS2((ref, is_upper), - trio_pointer_t ref, - int is_upper) -{ - if (is_upper) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_UPPER; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_UPPER; -} - -/************************************************************************* - * trio_get_largest / trio_set_largest [public] - */ -#if TRIO_C99 -int -trio_get_largest -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_INTMAX_T) - ? TRUE - : FALSE; -} - -void -trio_set_largest -TRIO_ARGS2((ref, is_largest), - trio_pointer_t ref, - int is_largest) -{ - if (is_largest) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_INTMAX_T; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_INTMAX_T; -} -#endif - -/************************************************************************* - * trio_get_ptrdiff / trio_set_ptrdiff [public] - */ -int -trio_get_ptrdiff -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_PTRDIFF_T) - ? TRUE - : FALSE; -} - -void -trio_set_ptrdiff -TRIO_ARGS2((ref, is_ptrdiff), - trio_pointer_t ref, - int is_ptrdiff) -{ - if (is_ptrdiff) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_PTRDIFF_T; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_PTRDIFF_T; -} - -/************************************************************************* - * trio_get_size / trio_set_size [public] - */ -#if TRIO_C99 -int -trio_get_size -TRIO_ARGS1((ref), - trio_pointer_t ref) -{ - return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SIZE_T) - ? TRUE - : FALSE; -} - -void -trio_set_size -TRIO_ARGS2((ref, is_size), - trio_pointer_t ref, - int is_size) -{ - if (is_size) - ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SIZE_T; - else - ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SIZE_T; -} -#endif - -/************************************************************************* - * trio_print_int [public] - */ -void -trio_print_int -TRIO_ARGS2((ref, number), - trio_pointer_t ref, - int number) -{ - trio_reference_t *self = (trio_reference_t *)ref; - - TrioWriteNumber(self->data, - (trio_uintmax_t)number, - self->parameter->flags, - self->parameter->width, - self->parameter->precision, - self->parameter->base); -} - -/************************************************************************* - * trio_print_uint [public] - */ -void -trio_print_uint -TRIO_ARGS2((ref, number), - trio_pointer_t ref, - unsigned int number) -{ - trio_reference_t *self = (trio_reference_t *)ref; - - TrioWriteNumber(self->data, - (trio_uintmax_t)number, - self->parameter->flags | FLAGS_UNSIGNED, - self->parameter->width, - self->parameter->precision, - self->parameter->base); -} - -/************************************************************************* - * trio_print_double [public] - */ -void -trio_print_double -TRIO_ARGS2((ref, number), - trio_pointer_t ref, - double number) -{ - trio_reference_t *self = (trio_reference_t *)ref; - - TrioWriteDouble(self->data, - number, - self->parameter->flags, - self->parameter->width, - self->parameter->precision, - self->parameter->base); -} - -/************************************************************************* - * trio_print_string [public] - */ -void -trio_print_string -TRIO_ARGS2((ref, string), - trio_pointer_t ref, - char *string) -{ - trio_reference_t *self = (trio_reference_t *)ref; - - TrioWriteString(self->data, - string, - self->parameter->flags, - self->parameter->width, - self->parameter->precision); -} - -/************************************************************************* - * trio_print_ref [public] - */ -int -trio_print_ref -TRIO_VARGS3((ref, format, va_alist), - trio_pointer_t ref, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list arglist; - - assert(VALID(format)); - - TRIO_VA_START(arglist, format); - status = TrioFormatRef((trio_reference_t *)ref, format, TRIO_VA_LIST_ADDR(arglist), NULL); - TRIO_VA_END(arglist); - return status; -} - -/************************************************************************* - * trio_vprint_ref [public] - */ -int -trio_vprint_ref -TRIO_ARGS3((ref, format, arglist), - trio_pointer_t ref, - TRIO_CONST char *format, - va_list arglist) -{ - assert(VALID(format)); - - return TrioFormatRef((trio_reference_t *)ref, format, TRIO_VA_LIST_ADDR(arglist), NULL); -} - -/************************************************************************* - * trio_printv_ref [public] - */ -int -trio_printv_ref -TRIO_ARGS3((ref, format, argarray), - trio_pointer_t ref, - TRIO_CONST char *format, - trio_pointer_t *argarray) -{ - assert(VALID(format)); - - return TrioFormatRef((trio_reference_t *)ref, format, NULL, argarray); -} - -#endif /* TRIO_EXTENSION */ - -/************************************************************************* - * trio_print_pointer [public] - */ -void -trio_print_pointer -TRIO_ARGS2((ref, pointer), - trio_pointer_t ref, - trio_pointer_t pointer) -{ - trio_reference_t *self = (trio_reference_t *)ref; - trio_flags_t flags; - trio_uintmax_t number; - - if (NULL == pointer) - { - TRIO_CONST char *string = internalNullString; - while (*string) - self->data->OutStream(self->data, *string++); - } - else - { - /* - * The subtraction of the null pointer is a workaround - * to avoid a compiler warning. The performance overhead - * is negligible (and likely to be removed by an - * optimizing compiler). The (char *) casting is done - * to please ANSI C++. - */ - number = (trio_uintmax_t)((char *)pointer - (char *)0); - /* Shrink to size of pointer */ - number &= (trio_uintmax_t)-1; - flags = self->parameter->flags; - flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | - FLAGS_NILPADDING); - TrioWriteNumber(self->data, - number, - flags, - POINTER_WIDTH, - NO_PRECISION, - BASE_HEX); - } -} - -/** @} End of UserDefined documentation module */ - -/************************************************************************* - * - * LOCALES - * - ************************************************************************/ - -/************************************************************************* - * trio_locale_set_decimal_point - * - * Decimal point can only be one character. The input argument is a - * string to enable multibyte characters. At most MB_LEN_MAX characters - * will be used. - */ -TRIO_PUBLIC void -trio_locale_set_decimal_point -TRIO_ARGS1((decimalPoint), - char *decimalPoint) -{ -#if defined(USE_LOCALE) - if (NULL == internalLocaleValues) - { - TrioSetLocale(); - } -#endif - internalDecimalPointLength = trio_length(decimalPoint); - if (internalDecimalPointLength == 1) - { - internalDecimalPoint = *decimalPoint; - } - else - { - internalDecimalPoint = NIL; - trio_copy_max(internalDecimalPointString, - sizeof(internalDecimalPointString), - decimalPoint); - } -} - -/************************************************************************* - * trio_locale_set_thousand_separator - * - * See trio_locale_set_decimal_point - */ -TRIO_PUBLIC void -trio_locale_set_thousand_separator -TRIO_ARGS1((thousandSeparator), - char *thousandSeparator) -{ -#if defined(USE_LOCALE) - if (NULL == internalLocaleValues) - { - TrioSetLocale(); - } -#endif - trio_copy_max(internalThousandSeparator, - sizeof(internalThousandSeparator), - thousandSeparator); - internalThousandSeparatorLength = trio_length(internalThousandSeparator); -} - -/************************************************************************* - * trio_locale_set_grouping - * - * Array of bytes. Reversed order. - * - * CHAR_MAX : No further grouping - * 0 : Repeat last group for the remaining digits (not necessary - * as C strings are zero-terminated) - * n : Set current group to n - * - * Same order as the grouping attribute in LC_NUMERIC. - */ -TRIO_PUBLIC void -trio_locale_set_grouping -TRIO_ARGS1((grouping), - char *grouping) -{ -#if defined(USE_LOCALE) - if (NULL == internalLocaleValues) - { - TrioSetLocale(); - } -#endif - trio_copy_max(internalGrouping, - sizeof(internalGrouping), - grouping); -} - - -/************************************************************************* - * - * SCANNING - * - ************************************************************************/ - -/************************************************************************* - * TrioSkipWhitespaces - */ -TRIO_PRIVATE int -TrioSkipWhitespaces -TRIO_ARGS1((self), - trio_class_t *self) -{ - int ch; - - ch = self->current; - while (isspace(ch)) - { - self->InStream(self, &ch); - } - return ch; -} - -/************************************************************************* - * TrioGetCollation - */ -#if TRIO_EXTENSION -TRIO_PRIVATE void -TrioGetCollation(TRIO_NOARGS) -{ - int i; - int j; - int k; - char first[2]; - char second[2]; - - /* This is computationally expensive */ - first[1] = NIL; - second[1] = NIL; - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - { - k = 0; - first[0] = (char)i; - for (j = 0; j < MAX_CHARACTER_CLASS; j++) - { - second[0] = (char)j; - if (trio_equal_locale(first, second)) - internalCollationArray[i][k++] = (char)j; - } - internalCollationArray[i][k] = NIL; - } -} -#endif - -/************************************************************************* - * TrioGetCharacterClass - * - * FIXME: - * multibyte - */ -TRIO_PRIVATE int -TrioGetCharacterClass -TRIO_ARGS4((format, indexPointer, flagsPointer, characterclass), - TRIO_CONST char *format, - int *indexPointer, - trio_flags_t *flagsPointer, - int *characterclass) -{ - int index = *indexPointer; - int i; - char ch; - char range_begin; - char range_end; - - *flagsPointer &= ~FLAGS_EXCLUDE; - - if (format[index] == QUALIFIER_CIRCUMFLEX) - { - *flagsPointer |= FLAGS_EXCLUDE; - index++; - } - /* - * If the ungroup character is at the beginning of the scanlist, - * it will be part of the class, and a second ungroup character - * must follow to end the group. - */ - if (format[index] == SPECIFIER_UNGROUP) - { - characterclass[(int)SPECIFIER_UNGROUP]++; - index++; - } - /* - * Minus is used to specify ranges. To include minus in the class, - * it must be at the beginning of the list - */ - if (format[index] == QUALIFIER_MINUS) - { - characterclass[(int)QUALIFIER_MINUS]++; - index++; - } - /* Collect characters */ - for (ch = format[index]; - (ch != SPECIFIER_UNGROUP) && (ch != NIL); - ch = format[++index]) - { - switch (ch) - { - case QUALIFIER_MINUS: /* Scanlist ranges */ - - /* - * Both C99 and UNIX98 describes ranges as implementation- - * defined. - * - * We support the following behaviour (although this may - * change as we become wiser) - * - only increasing ranges, ie. [a-b] but not [b-a] - * - transitive ranges, ie. [a-b-c] == [a-c] - * - trailing minus, ie. [a-] is interpreted as an 'a' - * and a '-' - * - duplicates (although we can easily convert these - * into errors) - */ - range_begin = format[index - 1]; - range_end = format[++index]; - if (range_end == SPECIFIER_UNGROUP) - { - /* Trailing minus is included */ - characterclass[(int)ch]++; - ch = range_end; - break; /* for */ - } - if (range_end == NIL) - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - if (range_begin > range_end) - return TRIO_ERROR_RETURN(TRIO_ERANGE, index); - - for (i = (int)range_begin; i <= (int)range_end; i++) - characterclass[i]++; - - ch = range_end; - break; - -#if TRIO_EXTENSION - - case SPECIFIER_GROUP: - - switch (format[index + 1]) - { - case QUALIFIER_DOT: /* Collating symbol */ - /* - * FIXME: This will be easier to implement when multibyte - * characters have been implemented. Until now, we ignore - * this feature. - */ - for (i = index + 2; ; i++) - { - if (format[i] == NIL) - /* Error in syntax */ - return -1; - else if (format[i] == QUALIFIER_DOT) - break; /* for */ - } - if (format[++i] != SPECIFIER_UNGROUP) - return -1; - - index = i; - break; - - case QUALIFIER_EQUAL: /* Equivalence class expressions */ - { - unsigned int j; - unsigned int k; - - if (internalCollationUnconverted) - { - /* Lazy evaluation of collation array */ - TrioGetCollation(); - internalCollationUnconverted = FALSE; - } - for (i = index + 2; ; i++) - { - if (format[i] == NIL) - /* Error in syntax */ - return -1; - else if (format[i] == QUALIFIER_EQUAL) - break; /* for */ - else - { - /* Mark any equivalent character */ - k = (unsigned int)format[i]; - for (j = 0; internalCollationArray[k][j] != NIL; j++) - characterclass[(int)internalCollationArray[k][j]]++; - } - } - if (format[++i] != SPECIFIER_UNGROUP) - return -1; - - index = i; - } - break; - - case QUALIFIER_COLON: /* Character class expressions */ - - if (trio_equal_max(CLASS_ALNUM, sizeof(CLASS_ALNUM) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isalnum(i)) - characterclass[i]++; - index += sizeof(CLASS_ALNUM) - 1; - } - else if (trio_equal_max(CLASS_ALPHA, sizeof(CLASS_ALPHA) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isalpha(i)) - characterclass[i]++; - index += sizeof(CLASS_ALPHA) - 1; - } - else if (trio_equal_max(CLASS_CNTRL, sizeof(CLASS_CNTRL) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (iscntrl(i)) - characterclass[i]++; - index += sizeof(CLASS_CNTRL) - 1; - } - else if (trio_equal_max(CLASS_DIGIT, sizeof(CLASS_DIGIT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isdigit(i)) - characterclass[i]++; - index += sizeof(CLASS_DIGIT) - 1; - } - else if (trio_equal_max(CLASS_GRAPH, sizeof(CLASS_GRAPH) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isgraph(i)) - characterclass[i]++; - index += sizeof(CLASS_GRAPH) - 1; - } - else if (trio_equal_max(CLASS_LOWER, sizeof(CLASS_LOWER) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (islower(i)) - characterclass[i]++; - index += sizeof(CLASS_LOWER) - 1; - } - else if (trio_equal_max(CLASS_PRINT, sizeof(CLASS_PRINT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isprint(i)) - characterclass[i]++; - index += sizeof(CLASS_PRINT) - 1; - } - else if (trio_equal_max(CLASS_PUNCT, sizeof(CLASS_PUNCT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (ispunct(i)) - characterclass[i]++; - index += sizeof(CLASS_PUNCT) - 1; - } - else if (trio_equal_max(CLASS_SPACE, sizeof(CLASS_SPACE) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isspace(i)) - characterclass[i]++; - index += sizeof(CLASS_SPACE) - 1; - } - else if (trio_equal_max(CLASS_UPPER, sizeof(CLASS_UPPER) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isupper(i)) - characterclass[i]++; - index += sizeof(CLASS_UPPER) - 1; - } - else if (trio_equal_max(CLASS_XDIGIT, sizeof(CLASS_XDIGIT) - 1, - &format[index])) - { - for (i = 0; i < MAX_CHARACTER_CLASS; i++) - if (isxdigit(i)) - characterclass[i]++; - index += sizeof(CLASS_XDIGIT) - 1; - } - else - { - characterclass[(int)ch]++; - } - break; - - default: - characterclass[(int)ch]++; - break; - } - break; - -#endif /* TRIO_EXTENSION */ - - default: - characterclass[(int)ch]++; - break; - } - } - return 0; -} - -/************************************************************************* - * TrioReadNumber - * - * We implement our own number conversion in preference of strtol and - * strtoul, because we must handle 'long long' and thousand separators. - */ -TRIO_PRIVATE BOOLEAN_T -TrioReadNumber -TRIO_ARGS5((self, target, flags, width, base), - trio_class_t *self, - trio_uintmax_t *target, - trio_flags_t flags, - int width, - int base) -{ - trio_uintmax_t number = 0; - int digit; - int count; - BOOLEAN_T isNegative = FALSE; - BOOLEAN_T gotNumber = FALSE; - int j; - - assert(VALID(self)); - assert(VALID(self->InStream)); - assert((base >= MIN_BASE && base <= MAX_BASE) || (base == NO_BASE)); - - if (internalDigitsUnconverted) - { - /* Lazy evaluation of digits array */ - memset(internalDigitArray, -1, sizeof(internalDigitArray)); - for (j = 0; j < (int)sizeof(internalDigitsLower) - 1; j++) - { - internalDigitArray[(int)internalDigitsLower[j]] = j; - internalDigitArray[(int)internalDigitsUpper[j]] = j; - } - internalDigitsUnconverted = FALSE; - } - - TrioSkipWhitespaces(self); - - if (!(flags & FLAGS_UNSIGNED)) - { - /* Leading sign */ - if (self->current == '+') - { - self->InStream(self, NULL); - } - else if (self->current == '-') - { - self->InStream(self, NULL); - isNegative = TRUE; - } - } - - count = self->processed; - - if (flags & FLAGS_ALTERNATIVE) - { - switch (base) - { - case NO_BASE: - case BASE_OCTAL: - case BASE_HEX: - case BASE_BINARY: - if (self->current == '0') - { - self->InStream(self, NULL); - if (self->current) - { - if ((base == BASE_HEX) && - (trio_to_upper(self->current) == 'X')) - { - self->InStream(self, NULL); - } - else if ((base == BASE_BINARY) && - (trio_to_upper(self->current) == 'B')) - { - self->InStream(self, NULL); - } - } - } - else - return FALSE; - break; - default: - break; - } - } - - while (((width == NO_WIDTH) || (self->processed - count < width)) && - (! ((self->current == EOF) || isspace(self->current)))) - { - if (isascii(self->current)) - { - digit = internalDigitArray[self->current]; - /* Abort if digit is not allowed in the specified base */ - if ((digit == -1) || (digit >= base)) - break; - } - else if (flags & FLAGS_QUOTE) - { - /* Compare with thousands separator */ - for (j = 0; internalThousandSeparator[j] && self->current; j++) - { - if (internalThousandSeparator[j] != self->current) - break; - - self->InStream(self, NULL); - } - if (internalThousandSeparator[j]) - break; /* Mismatch */ - else - continue; /* Match */ - } - else - break; - - number *= base; - number += digit; - gotNumber = TRUE; /* we need at least one digit */ - - self->InStream(self, NULL); - } - - /* Was anything read at all? */ - if (!gotNumber) - return FALSE; - - if (target) - *target = (isNegative) ? -((trio_intmax_t)number) : number; - return TRUE; -} - -/************************************************************************* - * TrioReadChar - */ -TRIO_PRIVATE int -TrioReadChar -TRIO_ARGS4((self, target, flags, width), - trio_class_t *self, - char *target, - trio_flags_t flags, - int width) -{ - int i; - char ch; - trio_uintmax_t number; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - for (i = 0; - (self->current != EOF) && (i < width); - i++) - { - ch = (char)self->current; - self->InStream(self, NULL); - if ((flags & FLAGS_ALTERNATIVE) && (ch == CHAR_BACKSLASH)) - { - switch (self->current) - { - case '\\': ch = '\\'; break; - case 'a': ch = '\007'; break; - case 'b': ch = '\b'; break; - case 'f': ch = '\f'; break; - case 'n': ch = '\n'; break; - case 'r': ch = '\r'; break; - case 't': ch = '\t'; break; - case 'v': ch = '\v'; break; - default: - if (isdigit(self->current)) - { - /* Read octal number */ - if (!TrioReadNumber(self, &number, 0, 3, BASE_OCTAL)) - return 0; - ch = (char)number; - } - else if (trio_to_upper(self->current) == 'X') - { - /* Read hexadecimal number */ - self->InStream(self, NULL); - if (!TrioReadNumber(self, &number, 0, 2, BASE_HEX)) - return 0; - ch = (char)number; - } - else - { - ch = (char)self->current; - } - break; - } - } - - if (target) - target[i] = ch; - } - return i + 1; -} - -/************************************************************************* - * TrioReadString - */ -TRIO_PRIVATE BOOLEAN_T -TrioReadString -TRIO_ARGS4((self, target, flags, width), - trio_class_t *self, - char *target, - trio_flags_t flags, - int width) -{ - int i; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - TrioSkipWhitespaces(self); - - /* - * Continue until end of string is reached, a whitespace is encountered, - * or width is exceeded - */ - for (i = 0; - ((width == NO_WIDTH) || (i < width)) && - (! ((self->current == EOF) || isspace(self->current))); - i++) - { - if (TrioReadChar(self, (target ? &target[i] : 0), flags, 1) == 0) - break; /* for */ - } - if (target) - target[i] = NIL; - return TRUE; -} - -/************************************************************************* - * TrioReadWideChar - */ -#if TRIO_WIDECHAR -TRIO_PRIVATE int -TrioReadWideChar -TRIO_ARGS4((self, target, flags, width), - trio_class_t *self, - trio_wchar_t *target, - trio_flags_t flags, - int width) -{ - int i; - int j; - int size; - int amount = 0; - trio_wchar_t wch; - char buffer[MB_LEN_MAX + 1]; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - for (i = 0; - (self->current != EOF) && (i < width); - i++) - { - if (isascii(self->current)) - { - if (TrioReadChar(self, buffer, flags, 1) == 0) - return 0; - buffer[1] = NIL; - } - else - { - /* - * Collect a multibyte character, by enlarging buffer until - * it contains a fully legal multibyte character, or the - * buffer is full. - */ - j = 0; - do - { - buffer[j++] = (char)self->current; - buffer[j] = NIL; - self->InStream(self, NULL); - } - while ((j < (int)sizeof(buffer)) && (mblen(buffer, (size_t)j) != j)); - } - if (target) - { - size = mbtowc(&wch, buffer, sizeof(buffer)); - if (size > 0) - target[i] = wch; - } - amount += size; - self->InStream(self, NULL); - } - return amount; -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioReadWideString - */ -#if TRIO_WIDECHAR -TRIO_PRIVATE BOOLEAN_T -TrioReadWideString -TRIO_ARGS4((self, target, flags, width), - trio_class_t *self, - trio_wchar_t *target, - trio_flags_t flags, - int width) -{ - int i; - int size; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - TrioSkipWhitespaces(self); - -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - (void)mblen(NULL, 0); -#endif - - /* - * Continue until end of string is reached, a whitespace is encountered, - * or width is exceeded - */ - for (i = 0; - ((width == NO_WIDTH) || (i < width)) && - (! ((self->current == EOF) || isspace(self->current))); - ) - { - size = TrioReadWideChar(self, &target[i], flags, 1); - if (size == 0) - break; /* for */ - - i += size; - } - if (target) - target[i] = WCONST('\0'); - return TRUE; -} -#endif /* TRIO_WIDECHAR */ - -/************************************************************************* - * TrioReadGroup - * - * FIXME: characterclass does not work with multibyte characters - */ -TRIO_PRIVATE BOOLEAN_T -TrioReadGroup -TRIO_ARGS5((self, target, characterclass, flags, width), - trio_class_t *self, - char *target, - int *characterclass, - trio_flags_t flags, - int width) -{ - int ch; - int i; - - assert(VALID(self)); - assert(VALID(self->InStream)); - - ch = self->current; - for (i = 0; - ((width == NO_WIDTH) || (i < width)) && - (! ((ch == EOF) || - (((flags & FLAGS_EXCLUDE) != 0) ^ (characterclass[ch] == 0)))); - i++) - { - if (target) - target[i] = (char)ch; - self->InStream(self, &ch); - } - - if (target) - target[i] = NIL; - return TRUE; -} - -/************************************************************************* - * TrioReadDouble - * - * FIXME: - * add long double - * handle base - */ -TRIO_PRIVATE BOOLEAN_T -TrioReadDouble -TRIO_ARGS4((self, target, flags, width), - trio_class_t *self, - trio_pointer_t target, - trio_flags_t flags, - int width) -{ - int ch; - char doubleString[512]; - int index = 0; - int start; - int j; - BOOLEAN_T isHex = FALSE; - - doubleString[0] = 0; - - if ((width == NO_WIDTH) || (width > (int)sizeof(doubleString) - 1)) - width = sizeof(doubleString) - 1; - - TrioSkipWhitespaces(self); - - /* - * Read entire double number from stream. trio_to_double requires - * a string as input, but InStream can be anything, so we have to - * collect all characters. - */ - ch = self->current; - if ((ch == '+') || (ch == '-')) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - width--; - } - - start = index; - switch (ch) - { - case 'n': - case 'N': - /* Not-a-number */ - if (index != 0) - break; - /* FALLTHROUGH */ - case 'i': - case 'I': - /* Infinity */ - while (isalpha(ch) && (index - start < width)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - doubleString[index] = NIL; - - /* Case insensitive string comparison */ - if (trio_equal(&doubleString[start], INFINITE_UPPER) || - trio_equal(&doubleString[start], LONG_INFINITE_UPPER)) - { - if (flags & FLAGS_LONGDOUBLE) - { - if ((start == 1) && (doubleString[0] == '-')) - { - *((trio_long_double_t *)target) = trio_ninf(); - } - else - { - *((trio_long_double_t *)target) = trio_pinf(); - } - } - else - { - if ((start == 1) && (doubleString[0] == '-')) - { - *((double *)target) = trio_ninf(); - } - else - { - *((double *)target) = trio_pinf(); - } - } - return TRUE; - } - if (trio_equal(doubleString, NAN_UPPER)) - { - /* NaN must not have a preceding + nor - */ - if (flags & FLAGS_LONGDOUBLE) - { - *((trio_long_double_t *)target) = trio_nan(); - } - else - { - *((double *)target) = trio_nan(); - } - return TRUE; - } - return FALSE; - - case '0': - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - if (trio_to_upper(ch) == 'X') - { - isHex = TRUE; - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - break; - - default: - break; - } - - while ((ch != EOF) && (index - start < width)) - { - /* Integer part */ - if (isHex ? isxdigit(ch) : isdigit(ch)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - else if (flags & FLAGS_QUOTE) - { - /* Compare with thousands separator */ - for (j = 0; internalThousandSeparator[j] && self->current; j++) - { - if (internalThousandSeparator[j] != self->current) - break; - - self->InStream(self, &ch); - } - if (internalThousandSeparator[j]) - break; /* Mismatch */ - else - continue; /* Match */ - } - else - break; /* while */ - } - if (ch == '.') - { - /* Decimal part */ - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - while ((isHex ? isxdigit(ch) : isdigit(ch)) && - (index - start < width)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - if (isHex ? (trio_to_upper(ch) == 'P') : (trio_to_upper(ch) == 'E')) - { - /* Exponent */ - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - if ((ch == '+') || (ch == '-')) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - while (isdigit(ch) && (index - start < width)) - { - doubleString[index++] = (char)ch; - self->InStream(self, &ch); - } - } - } - - if ((index == start) || (*doubleString == NIL)) - return FALSE; - - doubleString[index] = 0; - - if (flags & FLAGS_LONGDOUBLE) - { - *((trio_long_double_t *)target) = trio_to_long_double(doubleString, NULL); - } - else - { - *((double *)target) = trio_to_double(doubleString, NULL); - } - return TRUE; -} - -/************************************************************************* - * TrioReadPointer - */ -TRIO_PRIVATE BOOLEAN_T -TrioReadPointer -TRIO_ARGS3((self, target, flags), - trio_class_t *self, - trio_pointer_t *target, - trio_flags_t flags) -{ - trio_uintmax_t number; - char buffer[sizeof(internalNullString)]; - - flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | FLAGS_NILPADDING); - - if (TrioReadNumber(self, - &number, - flags, - POINTER_WIDTH, - BASE_HEX)) - { - /* - * The strange assignment of number is a workaround for a compiler - * warning - */ - if (target) - *target = (char *)0 + number; - return TRUE; - } - else if (TrioReadString(self, - (flags & FLAGS_IGNORE) - ? NULL - : buffer, - 0, - sizeof(internalNullString) - 1)) - { - if (trio_equal_case(buffer, internalNullString)) - { - if (target) - *target = NULL; - return TRUE; - } - } - return FALSE; -} - -/************************************************************************* - * TrioScanProcess - */ -TRIO_PRIVATE int -TrioScanProcess -TRIO_ARGS3((data, format, parameters), - trio_class_t *data, - TRIO_CONST char *format, - trio_parameter_t *parameters) -{ -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - int charlen; - int cnt; -#endif - int assignment; - int ch; - int index; /* Index of format string */ - int i; /* Index of current parameter */ - trio_flags_t flags; - int width; - int base; - trio_pointer_t pointer; - - assignment = 0; - i = 0; - index = 0; - data->InStream(data, &ch); - -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - (void)mblen(NULL, 0); -#endif - - while (format[index]) - { -#if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) - if (! isascii(format[index])) - { - charlen = mblen(&format[index], MB_LEN_MAX); - if (charlen != -1) - { - /* Compare multibyte characters in format string */ - for (cnt = 0; cnt < charlen - 1; cnt++) - { - if (ch != format[index + cnt]) - { - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - data->InStream(data, &ch); - } - continue; /* while characters left in formatting string */ - } - } -#endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ - - if ((EOF == ch) && (parameters[i].type != FORMAT_COUNT)) - { - return (assignment > 0) ? assignment : EOF; - } - - if (CHAR_IDENTIFIER == format[index]) - { - if (CHAR_IDENTIFIER == format[index + 1]) - { - /* Two % in format matches one % in input stream */ - if (CHAR_IDENTIFIER == ch) - { - data->InStream(data, &ch); - index += 2; - continue; /* while format chars left */ - } - else - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - - /* Skip the parameter entries */ - while (parameters[i].type == FORMAT_PARAMETER) - i++; - - flags = parameters[i].flags; - /* Find width */ - width = parameters[i].width; - if (flags & FLAGS_WIDTH_PARAMETER) - { - /* Get width from parameter list */ - width = (int)parameters[width].data.number.as_signed; - } - /* Find base */ - base = parameters[i].base; - if (flags & FLAGS_BASE_PARAMETER) - { - /* Get base from parameter list */ - base = (int)parameters[base].data.number.as_signed; - } - - switch (parameters[i].type) - { - case FORMAT_INT: - { - trio_uintmax_t number; - - if (0 == base) - base = BASE_DECIMAL; - - if (!TrioReadNumber(data, - &number, - flags, - width, - base)) - return assignment; - - if (!(flags & FLAGS_IGNORE)) - { - assignment++; - - pointer = parameters[i].data.pointer; -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (flags & FLAGS_SIZE_T) - *(size_t *)pointer = (size_t)number; - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (flags & FLAGS_PTRDIFF_T) - *(ptrdiff_t *)pointer = (ptrdiff_t)number; - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (flags & FLAGS_INTMAX_T) - *(trio_intmax_t *)pointer = (trio_intmax_t)number; - else -#endif - if (flags & FLAGS_QUAD) - *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)number; - else if (flags & FLAGS_LONG) - *(long int *)pointer = (long int)number; - else if (flags & FLAGS_SHORT) - *(short int *)pointer = (short int)number; - else - *(int *)pointer = (int)number; - } - } - break; /* FORMAT_INT */ - - case FORMAT_STRING: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - if (!TrioReadWideString(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.wstring, - flags, - width)) - return assignment; - } - else -#endif - { - if (!TrioReadString(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.string, - flags, - width)) - return assignment; - } - if (!(flags & FLAGS_IGNORE)) - assignment++; - break; /* FORMAT_STRING */ - - case FORMAT_DOUBLE: - { - trio_pointer_t pointer; - - if (flags & FLAGS_IGNORE) - { - pointer = NULL; - } - else - { - pointer = (flags & FLAGS_LONGDOUBLE) - ? (trio_pointer_t)parameters[i].data.longdoublePointer - : (trio_pointer_t)parameters[i].data.doublePointer; - } - if (!TrioReadDouble(data, pointer, flags, width)) - { - return assignment; - } - if (!(flags & FLAGS_IGNORE)) - { - assignment++; - } - break; /* FORMAT_DOUBLE */ - } - case FORMAT_GROUP: - { - int characterclass[MAX_CHARACTER_CLASS + 1]; - int rc; - - /* Skip over modifiers */ - while (format[index] != SPECIFIER_GROUP) - { - index++; - } - /* Skip over group specifier */ - index++; - - memset(characterclass, 0, sizeof(characterclass)); - rc = TrioGetCharacterClass(format, - &index, - &flags, - characterclass); - if (rc < 0) - return rc; - - if (!TrioReadGroup(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.string, - characterclass, - flags, - parameters[i].width)) - return assignment; - if (!(flags & FLAGS_IGNORE)) - assignment++; - } - break; /* FORMAT_GROUP */ - - case FORMAT_COUNT: - pointer = parameters[i].data.pointer; - if (NULL != pointer) - { - int count = data->committed; - if (ch != EOF) - count--; /* a character is read, but is not consumed yet */ -#if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) - if (flags & FLAGS_SIZE_T) - *(size_t *)pointer = (size_t)count; - else -#endif -#if defined(QUALIFIER_PTRDIFF_T) - if (flags & FLAGS_PTRDIFF_T) - *(ptrdiff_t *)pointer = (ptrdiff_t)count; - else -#endif -#if defined(QUALIFIER_INTMAX_T) - if (flags & FLAGS_INTMAX_T) - *(trio_intmax_t *)pointer = (trio_intmax_t)count; - else -#endif - if (flags & FLAGS_QUAD) - { - *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)count; - } - else if (flags & FLAGS_LONG) - { - *(long int *)pointer = (long int)count; - } - else if (flags & FLAGS_SHORT) - { - *(short int *)pointer = (short int)count; - } - else - { - *(int *)pointer = (int)count; - } - } - break; /* FORMAT_COUNT */ - - case FORMAT_CHAR: -#if TRIO_WIDECHAR - if (flags & FLAGS_WIDECHAR) - { - if (TrioReadWideChar(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.wstring, - flags, - (width == NO_WIDTH) ? 1 : width) == 0) - return assignment; - } - else -#endif - { - if (TrioReadChar(data, - (flags & FLAGS_IGNORE) - ? NULL - : parameters[i].data.string, - flags, - (width == NO_WIDTH) ? 1 : width) == 0) - return assignment; - } - if (!(flags & FLAGS_IGNORE)) - assignment++; - break; /* FORMAT_CHAR */ - - case FORMAT_POINTER: - if (!TrioReadPointer(data, - (flags & FLAGS_IGNORE) - ? NULL - : (trio_pointer_t *)parameters[i].data.pointer, - flags)) - return assignment; - if (!(flags & FLAGS_IGNORE)) - assignment++; - break; /* FORMAT_POINTER */ - - case FORMAT_PARAMETER: - break; /* FORMAT_PARAMETER */ - - default: - return TRIO_ERROR_RETURN(TRIO_EINVAL, index); - } - ch = data->current; - index = parameters[i].indexAfterSpecifier; - i++; - } - else /* Not an % identifier */ - { - if (isspace((int)format[index])) - { - /* Whitespaces may match any amount of whitespaces */ - ch = TrioSkipWhitespaces(data); - } - else if (ch == format[index]) - { - data->InStream(data, &ch); - } - else - return assignment; - - index++; - } - } - return assignment; -} - -/************************************************************************* - * TrioScan - */ -TRIO_PRIVATE int -TrioScan -TRIO_ARGS6((source, sourceSize, InStream, format, arglist, argarray), - trio_pointer_t source, - size_t sourceSize, - void (*InStream) TRIO_PROTO((trio_class_t *, int *)), - TRIO_CONST char *format, - TRIO_VA_LIST_PTR arglist, - trio_pointer_t *argarray) -{ - int status; - trio_parameter_t parameters[MAX_PARAMETERS]; - trio_class_t data; - - assert(VALID(InStream)); - assert(VALID(format)); - - memset(&data, 0, sizeof(data)); - data.InStream = InStream; - data.location = (trio_pointer_t)source; - data.max = sourceSize; - data.error = 0; - -#if defined(USE_LOCALE) - if (NULL == internalLocaleValues) - { - TrioSetLocale(); - } -#endif - - status = TrioParse(TYPE_SCAN, format, parameters, arglist, argarray); - if (status < 0) - return status; - - status = TrioScanProcess(&data, format, parameters); - if (data.error != 0) - { - status = data.error; - } - return status; -} - -/************************************************************************* - * TrioInStreamFile - */ -TRIO_PRIVATE void -TrioInStreamFile -TRIO_ARGS2((self, intPointer), - trio_class_t *self, - int *intPointer) -{ - FILE *file; - - assert(VALID(self)); - assert(VALID(self->location)); - assert(VALID(file)); - - file = (FILE *)self->location; - - self->current = fgetc(file); - if (self->current == EOF) - { - self->error = (ferror(file)) - ? TRIO_ERROR_RETURN(TRIO_ERRNO, 0) - : TRIO_ERROR_RETURN(TRIO_EOF, 0); - } - else - { - self->processed++; - self->committed++; - } - - if (VALID(intPointer)) - { - *intPointer = self->current; - } -} - -/************************************************************************* - * TrioInStreamFileDescriptor - */ -TRIO_PRIVATE void -TrioInStreamFileDescriptor -TRIO_ARGS2((self, intPointer), - trio_class_t *self, - int *intPointer) -{ - int fd; - int size; - unsigned char input; - - assert(VALID(self)); - assert(VALID(self->location)); - - fd = *((int *)self->location); - - size = read(fd, &input, sizeof(char)); - if (size == -1) - { - self->error = TRIO_ERROR_RETURN(TRIO_ERRNO, 0); - self->current = EOF; - } - else - { - self->current = (size == 0) ? EOF : input; - } - if (self->current != EOF) - { - self->committed++; - self->processed++; - } - - if (VALID(intPointer)) - { - *intPointer = self->current; - } -} - -/************************************************************************* - * TrioInStreamCustom - */ -TRIO_PRIVATE void -TrioInStreamCustom -TRIO_ARGS2((self, intPointer), - trio_class_t *self, - int *intPointer) -{ - trio_custom_t *data; - - assert(VALID(self)); - assert(VALID(self->location)); - - data = (trio_custom_t *)self->location; - - self->current = (data->stream.in == NULL) - ? NIL - : (data->stream.in)(data->closure); - - if (self->current == NIL) - { - self->current = EOF; - } - else - { - self->processed++; - self->committed++; - } - - if (VALID(intPointer)) - { - *intPointer = self->current; - } -} - -/************************************************************************* - * TrioInStreamString - */ -TRIO_PRIVATE void -TrioInStreamString -TRIO_ARGS2((self, intPointer), - trio_class_t *self, - int *intPointer) -{ - unsigned char **buffer; - - assert(VALID(self)); - assert(VALID(self->location)); - - buffer = (unsigned char **)self->location; - self->current = (*buffer)[0]; - if (self->current == NIL) - { - self->current = EOF; - } - else - { - (*buffer)++; - self->processed++; - self->committed++; - } - - if (VALID(intPointer)) - { - *intPointer = self->current; - } -} - -/************************************************************************* - * - * Formatted scanning functions - * - ************************************************************************/ - -#if defined(TRIO_DOCUMENTATION) -# include "doc/doc_scanf.h" -#endif -/** @addtogroup Scanf - @{ -*/ - -/************************************************************************* - * scanf - */ - -/** - Scan characters from standard input stream. - - @param format Formatting string. - @param ... Arguments. - @return Number of scanned characters. - */ -TRIO_PUBLIC int -trio_scanf -TRIO_VARGS2((format, va_alist), - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioScan((trio_pointer_t)stdin, 0, - TrioInStreamFile, - format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -TRIO_PUBLIC int -trio_vscanf -TRIO_ARGS2((format, args), - TRIO_CONST char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioScan((trio_pointer_t)stdin, 0, - TrioInStreamFile, - format, TRIO_VA_LIST_ADDR(args), NULL); -} - -TRIO_PUBLIC int -trio_scanfv -TRIO_ARGS2((format, args), - TRIO_CONST char *format, - trio_pointer_t *args) -{ - assert(VALID(format)); - - return TrioScan((trio_pointer_t)stdin, 0, - TrioInStreamFile, - format, NULL, args); -} - -/************************************************************************* - * fscanf - */ -TRIO_PUBLIC int -trio_fscanf -TRIO_VARGS3((file, format, va_alist), - FILE *file, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(file)); - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioScan((trio_pointer_t)file, 0, - TrioInStreamFile, - format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -TRIO_PUBLIC int -trio_vfscanf -TRIO_ARGS3((file, format, args), - FILE *file, - TRIO_CONST char *format, - va_list args) -{ - assert(VALID(file)); - assert(VALID(format)); - - return TrioScan((trio_pointer_t)file, 0, - TrioInStreamFile, - format, TRIO_VA_LIST_ADDR(args), NULL); -} - -TRIO_PUBLIC int -trio_fscanfv -TRIO_ARGS3((file, format, args), - FILE *file, - TRIO_CONST char *format, - trio_pointer_t *args) -{ - assert(VALID(file)); - assert(VALID(format)); - - return TrioScan((trio_pointer_t)file, 0, - TrioInStreamFile, - format, NULL, args); -} - -/************************************************************************* - * dscanf - */ -TRIO_PUBLIC int -trio_dscanf -TRIO_VARGS3((fd, format, va_alist), - int fd, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioScan((trio_pointer_t)&fd, 0, - TrioInStreamFileDescriptor, - format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -TRIO_PUBLIC int -trio_vdscanf -TRIO_ARGS3((fd, format, args), - int fd, - TRIO_CONST char *format, - va_list args) -{ - assert(VALID(format)); - - return TrioScan((trio_pointer_t)&fd, 0, - TrioInStreamFileDescriptor, - format, TRIO_VA_LIST_ADDR(args), NULL); -} - -TRIO_PUBLIC int -trio_dscanfv -TRIO_ARGS3((fd, format, args), - int fd, - TRIO_CONST char *format, - trio_pointer_t *args) -{ - assert(VALID(format)); - - return TrioScan((trio_pointer_t)&fd, 0, - TrioInStreamFileDescriptor, - format, NULL, args); -} - -/************************************************************************* - * cscanf - */ -TRIO_PUBLIC int -trio_cscanf -TRIO_VARGS4((stream, closure, format, va_alist), - trio_instream_t stream, - trio_pointer_t closure, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - trio_custom_t data; - - assert(VALID(stream)); - assert(VALID(format)); - - TRIO_VA_START(args, format); - data.stream.in = stream; - data.closure = closure; - status = TrioScan(&data, 0, TrioInStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -TRIO_PUBLIC int -trio_vcscanf -TRIO_ARGS4((stream, closure, format, args), - trio_instream_t stream, - trio_pointer_t closure, - TRIO_CONST char *format, - va_list args) -{ - trio_custom_t data; - - assert(VALID(stream)); - assert(VALID(format)); - - data.stream.in = stream; - data.closure = closure; - return TrioScan(&data, 0, TrioInStreamCustom, format, TRIO_VA_LIST_ADDR(args), NULL); -} - -TRIO_PUBLIC int -trio_cscanfv -TRIO_ARGS4((stream, closure, format, args), - trio_instream_t stream, - trio_pointer_t closure, - TRIO_CONST char *format, - trio_pointer_t *args) -{ - trio_custom_t data; - - assert(VALID(stream)); - assert(VALID(format)); - - data.stream.in = stream; - data.closure = closure; - return TrioScan(&data, 0, TrioInStreamCustom, format, NULL, args); -} - -/************************************************************************* - * sscanf - */ -TRIO_PUBLIC int -trio_sscanf -TRIO_VARGS3((buffer, format, va_alist), - TRIO_CONST char *buffer, - TRIO_CONST char *format, - TRIO_VA_DECL) -{ - int status; - va_list args; - - assert(VALID(buffer)); - assert(VALID(format)); - - TRIO_VA_START(args, format); - status = TrioScan((trio_pointer_t)&buffer, 0, - TrioInStreamString, - format, TRIO_VA_LIST_ADDR(args), NULL); - TRIO_VA_END(args); - return status; -} - -TRIO_PUBLIC int -trio_vsscanf -TRIO_ARGS3((buffer, format, args), - TRIO_CONST char *buffer, - TRIO_CONST char *format, - va_list args) -{ - assert(VALID(buffer)); - assert(VALID(format)); - - return TrioScan((trio_pointer_t)&buffer, 0, - TrioInStreamString, - format, TRIO_VA_LIST_ADDR(args), NULL); -} - -TRIO_PUBLIC int -trio_sscanfv -TRIO_ARGS3((buffer, format, args), - TRIO_CONST char *buffer, - TRIO_CONST char *format, - trio_pointer_t *args) -{ - assert(VALID(buffer)); - assert(VALID(format)); - - return TrioScan((trio_pointer_t)&buffer, 0, - TrioInStreamString, - format, NULL, args); -} - -/** @} End of Scanf documentation module */ - -/************************************************************************* - * trio_strerror - */ -TRIO_PUBLIC TRIO_CONST char * -trio_strerror -TRIO_ARGS1((errorcode), - int errorcode) -{ - /* Textual versions of the error codes */ - switch (TRIO_ERROR_CODE(errorcode)) - { - case TRIO_EOF: - return "End of file"; - case TRIO_EINVAL: - return "Invalid argument"; - case TRIO_ETOOMANY: - return "Too many arguments"; - case TRIO_EDBLREF: - return "Double reference"; - case TRIO_EGAP: - return "Reference gap"; - case TRIO_ENOMEM: - return "Out of memory"; - case TRIO_ERANGE: - return "Invalid range"; - case TRIO_ECUSTOM: - return "Custom error"; - default: - return "Unknown"; - } -} diff --git a/trio.h b/trio.h deleted file mode 100644 index dcf96b631..000000000 --- a/trio.h +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************* - * - * http://ctrio.sourceforge.net/ - * - ************************************************************************/ - -#ifndef TRIO_TRIO_H -#define TRIO_TRIO_H - -#if !defined(WITHOUT_TRIO) - -/* - * Use autoconf defines if present. Packages using trio must define - * HAVE_CONFIG_H as a compiler option themselves. - */ -#if defined(TRIO_HAVE_CONFIG_H) -# include "config.h" -#endif - -#include "triodef.h" - -#include -#include -#if defined(TRIO_COMPILER_ANCIENT) -# include -#else -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Error codes. - * - * Remember to add a textual description to trio_strerror. - */ -enum { - TRIO_EOF = 1, - TRIO_EINVAL = 2, - TRIO_ETOOMANY = 3, - TRIO_EDBLREF = 4, - TRIO_EGAP = 5, - TRIO_ENOMEM = 6, - TRIO_ERANGE = 7, - TRIO_ERRNO = 8, - TRIO_ECUSTOM = 9 -}; - -/* Error macros */ -#define TRIO_ERROR_CODE(x) ((-(x)) & 0x00FF) -#define TRIO_ERROR_POSITION(x) ((-(x)) >> 8) -#define TRIO_ERROR_NAME(x) trio_strerror(x) - -typedef int (*trio_outstream_t) TRIO_PROTO((trio_pointer_t, int)); -typedef int (*trio_instream_t) TRIO_PROTO((trio_pointer_t)); - -TRIO_CONST char *trio_strerror TRIO_PROTO((int)); - -/************************************************************************* - * Print Functions - */ - -int trio_printf TRIO_PROTO((TRIO_CONST char *format, ...)); -int trio_vprintf TRIO_PROTO((TRIO_CONST char *format, va_list args)); -int trio_printfv TRIO_PROTO((TRIO_CONST char *format, void **args)); - -int trio_fprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...)); -int trio_vfprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args)); -int trio_fprintfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args)); - -int trio_dprintf TRIO_PROTO((int fd, TRIO_CONST char *format, ...)); -int trio_vdprintf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args)); -int trio_dprintfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args)); - -int trio_cprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure, - TRIO_CONST char *format, ...)); -int trio_vcprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure, - TRIO_CONST char *format, va_list args)); -int trio_cprintfv TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure, - TRIO_CONST char *format, void **args)); - -int trio_sprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, ...)); -int trio_vsprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, va_list args)); -int trio_sprintfv TRIO_PROTO((char *buffer, TRIO_CONST char *format, void **args)); - -int trio_snprintf TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...)); -int trio_vsnprintf TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format, - va_list args)); -int trio_snprintfv TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format, - void **args)); - -int trio_snprintfcat TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...)); -int trio_vsnprintfcat TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format, - va_list args)); - -char *trio_aprintf TRIO_PROTO((TRIO_CONST char *format, ...)); -char *trio_vaprintf TRIO_PROTO((TRIO_CONST char *format, va_list args)); - -int trio_asprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, ...)); -int trio_vasprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, va_list args)); - -/************************************************************************* - * Scan Functions - */ -int trio_scanf TRIO_PROTO((TRIO_CONST char *format, ...)); -int trio_vscanf TRIO_PROTO((TRIO_CONST char *format, va_list args)); -int trio_scanfv TRIO_PROTO((TRIO_CONST char *format, void **args)); - -int trio_fscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...)); -int trio_vfscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args)); -int trio_fscanfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args)); - -int trio_dscanf TRIO_PROTO((int fd, TRIO_CONST char *format, ...)); -int trio_vdscanf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args)); -int trio_dscanfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args)); - -int trio_cscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure, - TRIO_CONST char *format, ...)); -int trio_vcscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure, - TRIO_CONST char *format, va_list args)); -int trio_cscanfv TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure, - TRIO_CONST char *format, void **args)); - -int trio_sscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, ...)); -int trio_vsscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, va_list args)); -int trio_sscanfv TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, void **args)); - -/************************************************************************* - * Locale Functions - */ -void trio_locale_set_decimal_point TRIO_PROTO((char *decimalPoint)); -void trio_locale_set_thousand_separator TRIO_PROTO((char *thousandSeparator)); -void trio_locale_set_grouping TRIO_PROTO((char *grouping)); - -/************************************************************************* - * Renaming - */ -#ifdef TRIO_REPLACE_STDIO -/* Replace the functions */ -#ifndef HAVE_PRINTF -# undef printf -# define printf trio_printf -#endif -#ifndef HAVE_VPRINTF -# undef vprintf -# define vprintf trio_vprintf -#endif -#ifndef HAVE_FPRINTF -# undef fprintf -# define fprintf trio_fprintf -#endif -#ifndef HAVE_VFPRINTF -# undef vfprintf -# define vfprintf trio_vfprintf -#endif -#ifndef HAVE_SPRINTF -# undef sprintf -# define sprintf trio_sprintf -#endif -#ifndef HAVE_VSPRINTF -# undef vsprintf -# define vsprintf trio_vsprintf -#endif -#ifndef HAVE_SNPRINTF -# undef snprintf -# define snprintf trio_snprintf -#endif -#ifndef HAVE_VSNPRINTF -# undef vsnprintf -# define vsnprintf trio_vsnprintf -#endif -#ifndef HAVE_SCANF -# undef scanf -# define scanf trio_scanf -#endif -#ifndef HAVE_VSCANF -# undef vscanf -# define vscanf trio_vscanf -#endif -#ifndef HAVE_FSCANF -# undef fscanf -# define fscanf trio_fscanf -#endif -#ifndef HAVE_VFSCANF -# undef vfscanf -# define vfscanf trio_vfscanf -#endif -#ifndef HAVE_SSCANF -# undef sscanf -# define sscanf trio_sscanf -#endif -#ifndef HAVE_VSSCANF -# undef vsscanf -# define vsscanf trio_vsscanf -#endif -/* These aren't stdio functions, but we make them look similar */ -#define dprintf trio_dprintf -#define vdprintf trio_vdprintf -#define aprintf trio_aprintf -#define vaprintf trio_vaprintf -#define asprintf trio_asprintf -#define vasprintf trio_vasprintf -#define dscanf trio_dscanf -#define vdscanf trio_vdscanf -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* WITHOUT_TRIO */ - -#endif /* TRIO_TRIO_H */ diff --git a/triodef.h b/triodef.h deleted file mode 100644 index e101f6df5..000000000 --- a/triodef.h +++ /dev/null @@ -1,228 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 2001 Bjorn Reese - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -#ifndef TRIO_TRIODEF_H -#define TRIO_TRIODEF_H - -/************************************************************************* - * Platform and compiler support detection - */ -#if defined(__GNUC__) -# define TRIO_COMPILER_GCC -#elif defined(__SUNPRO_C) -# define TRIO_COMPILER_SUNPRO -#elif defined(__SUNPRO_CC) -# define TRIO_COMPILER_SUNPRO -# define __SUNPRO_C __SUNPRO_CC -#elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) -# define TRIO_COMPILER_XLC -#elif defined(_AIX) && !defined(__GNUC__) -# define TRIO_COMPILER_XLC /* Workaround for old xlc */ -#elif defined(__DECC) || defined(__DECCXX) -# define TRIO_COMPILER_DECC -#elif defined(__osf__) && defined(__LANGUAGE_C__) -# define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ -#elif defined(_MSC_VER) -# define TRIO_COMPILER_MSVC -#elif defined(__BORLANDC__) -# define TRIO_COMPILER_BCB -#endif - -#if defined(VMS) || defined(__VMS) -/* - * VMS is placed first to avoid identifying the platform as Unix - * based on the DECC compiler later on. - */ -# define TRIO_PLATFORM_VMS -#elif defined(__OS400__) -# define TRIO_PLATFORM_OS400 -#elif defined(unix) || defined(__unix) || defined(__unix__) -# define TRIO_PLATFORM_UNIX -#elif defined(TRIO_COMPILER_XLC) || defined(_AIX) -# define TRIO_PLATFORM_UNIX -#elif defined(TRIO_COMPILER_DECC) || defined(__osf___) -# define TRIO_PLATFORM_UNIX -#elif defined(__NetBSD__) -# define TRIO_PLATFORM_UNIX -#elif defined(__Lynx__) -# define TRIO_PLATFORM_UNIX -#elif defined(__QNX__) -# define TRIO_PLATFORM_UNIX -# define TRIO_PLATFORM_QNX -#elif defined(__CYGWIN__) -# define TRIO_PLATFORM_UNIX -#elif defined(AMIGA) && defined(TRIO_COMPILER_GCC) -# define TRIO_PLATFORM_UNIX -#elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32) -# define TRIO_PLATFORM_WIN32 -#elif defined(mpeix) || defined(__mpexl) -# define TRIO_PLATFORM_MPEIX -#endif - -#if defined(_AIX) -# define TRIO_PLATFORM_AIX -#elif defined(__hpux) -# define TRIO_PLATFORM_HPUX -#elif defined(sun) || defined(__sun__) -# if defined(__SVR4) || defined(__svr4__) -# define TRIO_PLATFORM_SOLARIS -# else -# define TRIO_PLATFORM_SUNOS -# endif -#endif - -#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) -# define TRIO_COMPILER_SUPPORTS_C89 -# if defined(__STDC_VERSION__) -# define TRIO_COMPILER_SUPPORTS_C90 -# if (__STDC_VERSION__ >= 199409L) -# define TRIO_COMPILER_SUPPORTS_C94 -# endif -# if (__STDC_VERSION__ >= 199901L) -# define TRIO_COMPILER_SUPPORTS_C99 -# endif -# elif defined(TRIO_COMPILER_SUNPRO) -# if (__SUNPRO_C >= 0x420) -# define TRIO_COMPILER_SUPPORTS_C94 -# endif -# endif -#elif defined(TRIO_COMPILER_XLC) && defined(__EXTENDED__) -# define TRIO_COMPILER_SUPPORTS_C89 -# define TRIO_COMPILER_SUPPORTS_C90 -# define TRIO_COMPILER_SUPPORTS_C94 -#endif - -#if defined(_XOPEN_SOURCE) -# if defined(_XOPEN_SOURCE_EXTENDED) -# define TRIO_COMPILER_SUPPORTS_UNIX95 -# endif -# if (_XOPEN_VERSION >= 500) -# define TRIO_COMPILER_SUPPORTS_UNIX98 -# endif -# if (_XOPEN_VERSION >= 600) -# define TRIO_COMPILER_SUPPORTS_UNIX01 -# endif -#endif - -/************************************************************************* - * Generic defines - */ - -#if !defined(TRIO_PUBLIC) -# define TRIO_PUBLIC -#endif -#if !defined(TRIO_PRIVATE) -# define TRIO_PRIVATE static -#endif - -#if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) -# define TRIO_COMPILER_ANCIENT -#endif - -#if defined(TRIO_COMPILER_ANCIENT) -# define TRIO_CONST -# define TRIO_VOLATILE -# define TRIO_SIGNED -typedef double trio_long_double_t; -typedef char * trio_pointer_t; -# define TRIO_SUFFIX_LONG(x) x -# define TRIO_PROTO(x) () -# define TRIO_NOARGS -# define TRIO_ARGS1(list,a1) list a1; -# define TRIO_ARGS2(list,a1,a2) list a1; a2; -# define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; -# define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; -# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; -# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; -# define TRIO_VARGS2(list,a1,a2) list a1; a2 -# define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 -# define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 -# define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 -# define TRIO_VA_DECL va_dcl -# define TRIO_VA_START(x,y) va_start(x) -# define TRIO_VA_END(x) va_end(x) -#else /* ANSI C */ -# define TRIO_CONST const -# define TRIO_VOLATILE volatile -# define TRIO_SIGNED signed -typedef long double trio_long_double_t; -typedef void * trio_pointer_t; -# define TRIO_SUFFIX_LONG(x) x ## L -# define TRIO_PROTO(x) x -# define TRIO_NOARGS void -# define TRIO_ARGS1(list,a1) (a1) -# define TRIO_ARGS2(list,a1,a2) (a1,a2) -# define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) -# define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) -# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) -# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) -# define TRIO_VARGS2 TRIO_ARGS2 -# define TRIO_VARGS3 TRIO_ARGS3 -# define TRIO_VARGS4 TRIO_ARGS4 -# define TRIO_VARGS5 TRIO_ARGS5 -# define TRIO_VA_DECL ... -# define TRIO_VA_START(x,y) va_start(x,y) -# define TRIO_VA_END(x) va_end(x) -#endif - -#if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) -# define TRIO_INLINE inline -#elif defined(TRIO_COMPILER_GCC) -# define TRIO_INLINE __inline__ -#elif defined(TRIO_COMPILER_MSVC) -# define TRIO_INLINE _inline -#elif defined(TRIO_COMPILER_BCB) -# define TRIO_INLINE __inline -#else -# define TRIO_INLINE -#endif - -/************************************************************************* - * Workarounds - */ - -#if defined(TRIO_PLATFORM_VMS) -/* - * Computations done with constants at compile time can trigger these - * even when compiling with IEEE enabled. - */ -# pragma message disable (UNDERFLOW, FLOATOVERFL) - -# if (__CRTL_VER < 80000000) -/* - * Although the compiler supports C99 language constructs, the C - * run-time library does not contain all C99 functions. - * - * This was the case for 70300022. Update the 80000000 value when - * it has been accurately determined what version of the library - * supports C99. - */ -# if defined(TRIO_COMPILER_SUPPORTS_C99) -# undef TRIO_COMPILER_SUPPORTS_C99 -# endif -# endif -#endif - -/* - * Not all preprocessors supports the LL token. - */ -#if defined(TRIO_COMPILER_BCB) -#else -# define TRIO_COMPILER_SUPPORTS_LL -#endif - -#endif /* TRIO_TRIODEF_H */ diff --git a/trionan.c b/trionan.c deleted file mode 100644 index 8767a9fe6..000000000 --- a/trionan.c +++ /dev/null @@ -1,914 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 2001 Bjorn Reese - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************ - * - * Functions to handle special quantities in floating-point numbers - * (that is, NaNs and infinity). They provide the capability to detect - * and fabricate special quantities. - * - * Although written to be as portable as possible, it can never be - * guaranteed to work on all platforms, as not all hardware supports - * special quantities. - * - * The approach used here (approximately) is to: - * - * 1. Use C99 functionality when available. - * 2. Use IEEE 754 bit-patterns if possible. - * 3. Use platform-specific techniques. - * - ************************************************************************/ - -/* - * TODO: - * o Put all the magic into trio_fpclassify_and_signbit(), and use this from - * trio_isnan() etc. - */ - -/************************************************************************* - * Include files - */ -#include "triodef.h" -#include "trionan.h" - -#include -#include -#include -#include -#if defined(TRIO_PLATFORM_UNIX) -# include -#endif -#if defined(TRIO_COMPILER_DECC) -# if defined(__linux__) -# include -# else -# include -# endif -#endif -#include - -#if defined(TRIO_DOCUMENTATION) -# include "doc/doc_nan.h" -#endif -/** @addtogroup SpecialQuantities - @{ -*/ - -/************************************************************************* - * Definitions - */ - -#define TRIO_TRUE (1 == 1) -#define TRIO_FALSE (0 == 1) - -/* - * We must enable IEEE floating-point on Alpha - */ -#if defined(__alpha) && !defined(_IEEE_FP) -# if defined(TRIO_COMPILER_DECC) -# if defined(TRIO_PLATFORM_VMS) -# error "Must be compiled with option /IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE" -# else -# if !defined(_CFE) -# error "Must be compiled with option -ieee" -# endif -# endif -# elif defined(TRIO_COMPILER_GCC) && (defined(__osf__) || defined(__linux__)) -# error "Must be compiled with option -mieee" -# endif -#endif /* __alpha && ! _IEEE_FP */ - -/* - * In ANSI/IEEE 754-1985 64-bits double format numbers have the - * following properties (amongst others) - * - * o FLT_RADIX == 2: binary encoding - * o DBL_MAX_EXP == 1024: 11 bits exponent, where one bit is used - * to indicate special numbers (e.g. NaN and Infinity), so the - * maximum exponent is 10 bits wide (2^10 == 1024). - * o DBL_MANT_DIG == 53: The mantissa is 52 bits wide, but because - * numbers are normalized the initial binary 1 is represented - * implicitly (the so-called "hidden bit"), which leaves us with - * the ability to represent 53 bits wide mantissa. - */ -#if (FLT_RADIX == 2) && (DBL_MAX_EXP == 1024) && (DBL_MANT_DIG == 53) -# define USE_IEEE_754 -#endif - - -/************************************************************************* - * Constants - */ - -static TRIO_CONST char rcsid[] = "@(#)$Id$"; - -#if defined(USE_IEEE_754) - -/* - * Endian-agnostic indexing macro. - * - * The value of internalEndianMagic, when converted into a 64-bit - * integer, becomes 0x0706050403020100 (we could have used a 64-bit - * integer value instead of a double, but not all platforms supports - * that type). The value is automatically encoded with the correct - * endianness by the compiler, which means that we can support any - * kind of endianness. The individual bytes are then used as an index - * for the IEEE 754 bit-patterns and masks. - */ -#define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)]) - -#if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0590) -static TRIO_CONST double internalEndianMagic = 7.949928895127362e-275; -#else -static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275; -#endif - -/* Mask for the exponent */ -static TRIO_CONST unsigned char ieee_754_exponent_mask[] = { - 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* Mask for the mantissa */ -static TRIO_CONST unsigned char ieee_754_mantissa_mask[] = { - 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; - -/* Mask for the sign bit */ -static TRIO_CONST unsigned char ieee_754_sign_mask[] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* Bit-pattern for negative zero */ -static TRIO_CONST unsigned char ieee_754_negzero_array[] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* Bit-pattern for infinity */ -static TRIO_CONST unsigned char ieee_754_infinity_array[] = { - 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* Bit-pattern for quiet NaN */ -static TRIO_CONST unsigned char ieee_754_qnan_array[] = { - 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - - -/************************************************************************* - * Functions - */ - -/* - * trio_make_double - */ -TRIO_PRIVATE double -trio_make_double -TRIO_ARGS1((values), - TRIO_CONST unsigned char *values) -{ - TRIO_VOLATILE double result; - int i; - - for (i = 0; i < (int)sizeof(double); i++) { - ((TRIO_VOLATILE unsigned char *)&result)[TRIO_DOUBLE_INDEX(i)] = values[i]; - } - return result; -} - -/* - * trio_is_special_quantity - */ -TRIO_PRIVATE int -trio_is_special_quantity -TRIO_ARGS2((number, has_mantissa), - double number, - int *has_mantissa) -{ - unsigned int i; - unsigned char current; - int is_special_quantity = TRIO_TRUE; - - *has_mantissa = 0; - - for (i = 0; i < (unsigned int)sizeof(double); i++) { - current = ((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)]; - is_special_quantity - &= ((current & ieee_754_exponent_mask[i]) == ieee_754_exponent_mask[i]); - *has_mantissa |= (current & ieee_754_mantissa_mask[i]); - } - return is_special_quantity; -} - -/* - * trio_is_negative - */ -TRIO_PRIVATE int -trio_is_negative -TRIO_ARGS1((number), - double number) -{ - unsigned int i; - int is_negative = TRIO_FALSE; - - for (i = 0; i < (unsigned int)sizeof(double); i++) { - is_negative |= (((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)] - & ieee_754_sign_mask[i]); - } - return is_negative; -} - -#endif /* USE_IEEE_754 */ - - -/** - Generate negative zero. - - @return Floating-point representation of negative zero. -*/ -TRIO_PUBLIC double -trio_nzero(TRIO_NOARGS) -{ -#if defined(USE_IEEE_754) - return trio_make_double(ieee_754_negzero_array); -#else - TRIO_VOLATILE double zero = 0.0; - - return -zero; -#endif -} - -/** - Generate positive infinity. - - @return Floating-point representation of positive infinity. -*/ -TRIO_PUBLIC double -trio_pinf(TRIO_NOARGS) -{ - /* Cache the result */ - static double result = 0.0; - - if (result == 0.0) { - -#if defined(INFINITY) && defined(__STDC_IEC_559__) - result = (double)INFINITY; - -#elif defined(USE_IEEE_754) - result = trio_make_double(ieee_754_infinity_array); - -#else - /* - * If HUGE_VAL is different from DBL_MAX, then HUGE_VAL is used - * as infinity. Otherwise we have to resort to an overflow - * operation to generate infinity. - */ -# if defined(TRIO_PLATFORM_UNIX) - void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); -# endif - - result = HUGE_VAL; - if (HUGE_VAL == DBL_MAX) { - /* Force overflow */ - result += HUGE_VAL; - } - -# if defined(TRIO_PLATFORM_UNIX) - signal(SIGFPE, signal_handler); -# endif - -#endif - } - return result; -} - -/** - Generate negative infinity. - - @return Floating-point value of negative infinity. -*/ -TRIO_PUBLIC double -trio_ninf(TRIO_NOARGS) -{ - static double result = 0.0; - - if (result == 0.0) { - /* - * Negative infinity is calculated by negating positive infinity, - * which can be done because it is legal to do calculations on - * infinity (for example, 1 / infinity == 0). - */ - result = -trio_pinf(); - } - return result; -} - -/** - Generate NaN. - - @return Floating-point representation of NaN. -*/ -TRIO_PUBLIC double -trio_nan(TRIO_NOARGS) -{ - /* Cache the result */ - static double result = 0.0; - - if (result == 0.0) { - -#if defined(TRIO_COMPILER_SUPPORTS_C99) - result = nan(""); - -#elif defined(NAN) && defined(__STDC_IEC_559__) - result = (double)NAN; - -#elif defined(USE_IEEE_754) - result = trio_make_double(ieee_754_qnan_array); - -#else - /* - * There are several ways to generate NaN. The one used here is - * to divide infinity by infinity. I would have preferred to add - * negative infinity to positive infinity, but that yields wrong - * result (infinity) on FreeBSD. - * - * This may fail if the hardware does not support NaN, or if - * the Invalid Operation floating-point exception is unmasked. - */ -# if defined(TRIO_PLATFORM_UNIX) - void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); -# endif - - result = trio_pinf() / trio_pinf(); - -# if defined(TRIO_PLATFORM_UNIX) - signal(SIGFPE, signal_handler); -# endif - -#endif - } - return result; -} - -/** - Check for NaN. - - @param number An arbitrary floating-point number. - @return Boolean value indicating whether or not the number is a NaN. -*/ -TRIO_PUBLIC int -trio_isnan -TRIO_ARGS1((number), - double number) -{ -#if (defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isnan)) \ - || defined(TRIO_COMPILER_SUPPORTS_UNIX95) - /* - * C99 defines isnan() as a macro. UNIX95 defines isnan() as a - * function. This function was already present in XPG4, but this - * is a bit tricky to detect with compiler defines, so we choose - * the conservative approach and only use it for UNIX95. - */ - return isnan(number); - -#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) - /* - * Microsoft Visual C++ and Borland C++ Builder have an _isnan() - * function. - */ - return _isnan(number) ? TRIO_TRUE : TRIO_FALSE; - -#elif defined(USE_IEEE_754) - /* - * Examine IEEE 754 bit-pattern. A NaN must have a special exponent - * pattern, and a non-empty mantissa. - */ - int has_mantissa; - int is_special_quantity; - - is_special_quantity = trio_is_special_quantity(number, &has_mantissa); - - return (is_special_quantity && has_mantissa); - -#else - /* - * Fallback solution - */ - int status; - double integral, fraction; - -# if defined(TRIO_PLATFORM_UNIX) - void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); -# endif - - status = (/* - * NaN is the only number which does not compare to itself - */ - ((TRIO_VOLATILE double)number != (TRIO_VOLATILE double)number) || - /* - * Fallback solution if NaN compares to NaN - */ - ((number != 0.0) && - (fraction = modf(number, &integral), - integral == fraction))); - -# if defined(TRIO_PLATFORM_UNIX) - signal(SIGFPE, signal_handler); -# endif - - return status; - -#endif -} - -/** - Check for infinity. - - @param number An arbitrary floating-point number. - @return 1 if positive infinity, -1 if negative infinity, 0 otherwise. -*/ -TRIO_PUBLIC int -trio_isinf -TRIO_ARGS1((number), - double number) -{ -#if defined(TRIO_COMPILER_DECC) && !defined(__linux__) - /* - * DECC has an isinf() macro, but it works differently than that - * of C99, so we use the fp_class() function instead. - */ - return ((fp_class(number) == FP_POS_INF) - ? 1 - : ((fp_class(number) == FP_NEG_INF) ? -1 : 0)); - -#elif defined(isinf) - /* - * C99 defines isinf() as a macro. - */ - return isinf(number) - ? ((number > 0.0) ? 1 : -1) - : 0; - -#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) - /* - * Microsoft Visual C++ and Borland C++ Builder have an _fpclass() - * function that can be used to detect infinity. - */ - return ((_fpclass(number) == _FPCLASS_PINF) - ? 1 - : ((_fpclass(number) == _FPCLASS_NINF) ? -1 : 0)); - -#elif defined(USE_IEEE_754) - /* - * Examine IEEE 754 bit-pattern. Infinity must have a special exponent - * pattern, and an empty mantissa. - */ - int has_mantissa; - int is_special_quantity; - - is_special_quantity = trio_is_special_quantity(number, &has_mantissa); - - return (is_special_quantity && !has_mantissa) - ? ((number < 0.0) ? -1 : 1) - : 0; - -#else - /* - * Fallback solution. - */ - int status; - -# if defined(TRIO_PLATFORM_UNIX) - void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); -# endif - - double infinity = trio_pinf(); - - status = ((number == infinity) - ? 1 - : ((number == -infinity) ? -1 : 0)); - -# if defined(TRIO_PLATFORM_UNIX) - signal(SIGFPE, signal_handler); -# endif - - return status; - -#endif -} - -#if 0 - /* Temporary fix - this routine is not used anywhere */ -/** - Check for finity. - - @param number An arbitrary floating-point number. - @return Boolean value indicating whether or not the number is a finite. -*/ -TRIO_PUBLIC int -trio_isfinite -TRIO_ARGS1((number), - double number) -{ -#if defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isfinite) - /* - * C99 defines isfinite() as a macro. - */ - return isfinite(number); - -#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) - /* - * Microsoft Visual C++ and Borland C++ Builder use _finite(). - */ - return _finite(number); - -#elif defined(USE_IEEE_754) - /* - * Examine IEEE 754 bit-pattern. For finity we do not care about the - * mantissa. - */ - int dummy; - - return (! trio_is_special_quantity(number, &dummy)); - -#else - /* - * Fallback solution. - */ - return ((trio_isinf(number) == 0) && (trio_isnan(number) == 0)); - -#endif -} - -#endif - -/* - * The sign of NaN is always false - */ -TRIO_PUBLIC int -trio_fpclassify_and_signbit -TRIO_ARGS2((number, is_negative), - double number, - int *is_negative) -{ -#if defined(fpclassify) && defined(signbit) - /* - * C99 defines fpclassify() and signbit() as a macros - */ - *is_negative = signbit(number); - switch (fpclassify(number)) { - case FP_NAN: - return TRIO_FP_NAN; - case FP_INFINITE: - return TRIO_FP_INFINITE; - case FP_SUBNORMAL: - return TRIO_FP_SUBNORMAL; - case FP_ZERO: - return TRIO_FP_ZERO; - default: - return TRIO_FP_NORMAL; - } - -#else -# if defined(TRIO_COMPILER_DECC) - /* - * DECC has an fp_class() function. - */ -# define TRIO_FPCLASSIFY(n) fp_class(n) -# define TRIO_QUIET_NAN FP_QNAN -# define TRIO_SIGNALLING_NAN FP_SNAN -# define TRIO_POSITIVE_INFINITY FP_POS_INF -# define TRIO_NEGATIVE_INFINITY FP_NEG_INF -# define TRIO_POSITIVE_SUBNORMAL FP_POS_DENORM -# define TRIO_NEGATIVE_SUBNORMAL FP_NEG_DENORM -# define TRIO_POSITIVE_ZERO FP_POS_ZERO -# define TRIO_NEGATIVE_ZERO FP_NEG_ZERO -# define TRIO_POSITIVE_NORMAL FP_POS_NORM -# define TRIO_NEGATIVE_NORMAL FP_NEG_NORM - -# elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) - /* - * Microsoft Visual C++ and Borland C++ Builder have an _fpclass() - * function. - */ -# define TRIO_FPCLASSIFY(n) _fpclass(n) -# define TRIO_QUIET_NAN _FPCLASS_QNAN -# define TRIO_SIGNALLING_NAN _FPCLASS_SNAN -# define TRIO_POSITIVE_INFINITY _FPCLASS_PINF -# define TRIO_NEGATIVE_INFINITY _FPCLASS_NINF -# define TRIO_POSITIVE_SUBNORMAL _FPCLASS_PD -# define TRIO_NEGATIVE_SUBNORMAL _FPCLASS_ND -# define TRIO_POSITIVE_ZERO _FPCLASS_PZ -# define TRIO_NEGATIVE_ZERO _FPCLASS_NZ -# define TRIO_POSITIVE_NORMAL _FPCLASS_PN -# define TRIO_NEGATIVE_NORMAL _FPCLASS_NN - -# elif defined(FP_PLUS_NORM) - /* - * HP-UX 9.x and 10.x have an fpclassify() function, that is different - * from the C99 fpclassify() macro supported on HP-UX 11.x. - * - * AIX has class() for C, and _class() for C++, which returns the - * same values as the HP-UX fpclassify() function. - */ -# if defined(TRIO_PLATFORM_AIX) -# if defined(__cplusplus) -# define TRIO_FPCLASSIFY(n) _class(n) -# else -# define TRIO_FPCLASSIFY(n) class(n) -# endif -# else -# define TRIO_FPCLASSIFY(n) fpclassify(n) -# endif -# define TRIO_QUIET_NAN FP_QNAN -# define TRIO_SIGNALLING_NAN FP_SNAN -# define TRIO_POSITIVE_INFINITY FP_PLUS_INF -# define TRIO_NEGATIVE_INFINITY FP_MINUS_INF -# define TRIO_POSITIVE_SUBNORMAL FP_PLUS_DENORM -# define TRIO_NEGATIVE_SUBNORMAL FP_MINUS_DENORM -# define TRIO_POSITIVE_ZERO FP_PLUS_ZERO -# define TRIO_NEGATIVE_ZERO FP_MINUS_ZERO -# define TRIO_POSITIVE_NORMAL FP_PLUS_NORM -# define TRIO_NEGATIVE_NORMAL FP_MINUS_NORM -# endif - -# if defined(TRIO_FPCLASSIFY) - switch (TRIO_FPCLASSIFY(number)) { - case TRIO_QUIET_NAN: - case TRIO_SIGNALLING_NAN: - *is_negative = TRIO_FALSE; /* NaN has no sign */ - return TRIO_FP_NAN; - case TRIO_POSITIVE_INFINITY: - *is_negative = TRIO_FALSE; - return TRIO_FP_INFINITE; - case TRIO_NEGATIVE_INFINITY: - *is_negative = TRIO_TRUE; - return TRIO_FP_INFINITE; - case TRIO_POSITIVE_SUBNORMAL: - *is_negative = TRIO_FALSE; - return TRIO_FP_SUBNORMAL; - case TRIO_NEGATIVE_SUBNORMAL: - *is_negative = TRIO_TRUE; - return TRIO_FP_SUBNORMAL; - case TRIO_POSITIVE_ZERO: - *is_negative = TRIO_FALSE; - return TRIO_FP_ZERO; - case TRIO_NEGATIVE_ZERO: - *is_negative = TRIO_TRUE; - return TRIO_FP_ZERO; - case TRIO_POSITIVE_NORMAL: - *is_negative = TRIO_FALSE; - return TRIO_FP_NORMAL; - case TRIO_NEGATIVE_NORMAL: - *is_negative = TRIO_TRUE; - return TRIO_FP_NORMAL; - default: - /* Just in case... */ - *is_negative = (number < 0.0); - return TRIO_FP_NORMAL; - } - -# else - /* - * Fallback solution. - */ - int rc; - - if (number == 0.0) { - /* - * In IEEE 754 the sign of zero is ignored in comparisons, so we - * have to handle this as a special case by examining the sign bit - * directly. - */ -# if defined(USE_IEEE_754) - *is_negative = trio_is_negative(number); -# else - *is_negative = TRIO_FALSE; /* FIXME */ -# endif - return TRIO_FP_ZERO; - } - if (trio_isnan(number)) { - *is_negative = TRIO_FALSE; - return TRIO_FP_NAN; - } - if ((rc = trio_isinf(number))) { - *is_negative = (rc == -1); - return TRIO_FP_INFINITE; - } - if ((number > 0.0) && (number < DBL_MIN)) { - *is_negative = TRIO_FALSE; - return TRIO_FP_SUBNORMAL; - } - if ((number < 0.0) && (number > -DBL_MIN)) { - *is_negative = TRIO_TRUE; - return TRIO_FP_SUBNORMAL; - } - *is_negative = (number < 0.0); - return TRIO_FP_NORMAL; - -# endif -#endif -} - -/** - Examine the sign of a number. - - @param number An arbitrary floating-point number. - @return Boolean value indicating whether or not the number has the - sign bit set (i.e. is negative). -*/ -TRIO_PUBLIC int -trio_signbit -TRIO_ARGS1((number), - double number) -{ - int is_negative; - - (void)trio_fpclassify_and_signbit(number, &is_negative); - return is_negative; -} - -#if 0 - /* Temporary fix - this routine is not used in libxml */ -/** - Examine the class of a number. - - @param number An arbitrary floating-point number. - @return Enumerable value indicating the class of @p number -*/ -TRIO_PUBLIC int -trio_fpclassify -TRIO_ARGS1((number), - double number) -{ - int dummy; - - return trio_fpclassify_and_signbit(number, &dummy); -} - -#endif - -/** @} SpecialQuantities */ - -/************************************************************************* - * For test purposes. - * - * Add the following compiler option to include this test code. - * - * Unix : -DSTANDALONE - * VMS : /DEFINE=(STANDALONE) - */ -#if defined(STANDALONE) -# include - -static TRIO_CONST char * -getClassification -TRIO_ARGS1((type), - int type) -{ - switch (type) { - case TRIO_FP_INFINITE: - return "FP_INFINITE"; - case TRIO_FP_NAN: - return "FP_NAN"; - case TRIO_FP_NORMAL: - return "FP_NORMAL"; - case TRIO_FP_SUBNORMAL: - return "FP_SUBNORMAL"; - case TRIO_FP_ZERO: - return "FP_ZERO"; - default: - return "FP_UNKNOWN"; - } -} - -static void -print_class -TRIO_ARGS2((prefix, number), - TRIO_CONST char *prefix, - double number) -{ - printf("%-6s: %s %-15s %g\n", - prefix, - trio_signbit(number) ? "-" : "+", - getClassification(TRIO_FPCLASSIFY(number)), - number); -} - -int main(TRIO_NOARGS) -{ - double my_nan; - double my_pinf; - double my_ninf; -# if defined(TRIO_PLATFORM_UNIX) - void (*signal_handler) TRIO_PROTO((int)); -# endif - - my_nan = trio_nan(); - my_pinf = trio_pinf(); - my_ninf = trio_ninf(); - - print_class("Nan", my_nan); - print_class("PInf", my_pinf); - print_class("NInf", my_ninf); - print_class("PZero", 0.0); - print_class("NZero", -0.0); - print_class("PNorm", 1.0); - print_class("NNorm", -1.0); - print_class("PSub", 1.01e-307 - 1.00e-307); - print_class("NSub", 1.00e-307 - 1.01e-307); - - printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", - my_nan, - ((unsigned char *)&my_nan)[0], - ((unsigned char *)&my_nan)[1], - ((unsigned char *)&my_nan)[2], - ((unsigned char *)&my_nan)[3], - ((unsigned char *)&my_nan)[4], - ((unsigned char *)&my_nan)[5], - ((unsigned char *)&my_nan)[6], - ((unsigned char *)&my_nan)[7], - trio_isnan(my_nan), trio_isinf(my_nan)); - printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", - my_pinf, - ((unsigned char *)&my_pinf)[0], - ((unsigned char *)&my_pinf)[1], - ((unsigned char *)&my_pinf)[2], - ((unsigned char *)&my_pinf)[3], - ((unsigned char *)&my_pinf)[4], - ((unsigned char *)&my_pinf)[5], - ((unsigned char *)&my_pinf)[6], - ((unsigned char *)&my_pinf)[7], - trio_isnan(my_pinf), trio_isinf(my_pinf)); - printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", - my_ninf, - ((unsigned char *)&my_ninf)[0], - ((unsigned char *)&my_ninf)[1], - ((unsigned char *)&my_ninf)[2], - ((unsigned char *)&my_ninf)[3], - ((unsigned char *)&my_ninf)[4], - ((unsigned char *)&my_ninf)[5], - ((unsigned char *)&my_ninf)[6], - ((unsigned char *)&my_ninf)[7], - trio_isnan(my_ninf), trio_isinf(my_ninf)); - -# if defined(TRIO_PLATFORM_UNIX) - signal_handler = signal(SIGFPE, SIG_IGN); -# endif - - my_pinf = DBL_MAX + DBL_MAX; - my_ninf = -my_pinf; - my_nan = my_pinf / my_pinf; - -# if defined(TRIO_PLATFORM_UNIX) - signal(SIGFPE, signal_handler); -# endif - - printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", - my_nan, - ((unsigned char *)&my_nan)[0], - ((unsigned char *)&my_nan)[1], - ((unsigned char *)&my_nan)[2], - ((unsigned char *)&my_nan)[3], - ((unsigned char *)&my_nan)[4], - ((unsigned char *)&my_nan)[5], - ((unsigned char *)&my_nan)[6], - ((unsigned char *)&my_nan)[7], - trio_isnan(my_nan), trio_isinf(my_nan)); - printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", - my_pinf, - ((unsigned char *)&my_pinf)[0], - ((unsigned char *)&my_pinf)[1], - ((unsigned char *)&my_pinf)[2], - ((unsigned char *)&my_pinf)[3], - ((unsigned char *)&my_pinf)[4], - ((unsigned char *)&my_pinf)[5], - ((unsigned char *)&my_pinf)[6], - ((unsigned char *)&my_pinf)[7], - trio_isnan(my_pinf), trio_isinf(my_pinf)); - printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", - my_ninf, - ((unsigned char *)&my_ninf)[0], - ((unsigned char *)&my_ninf)[1], - ((unsigned char *)&my_ninf)[2], - ((unsigned char *)&my_ninf)[3], - ((unsigned char *)&my_ninf)[4], - ((unsigned char *)&my_ninf)[5], - ((unsigned char *)&my_ninf)[6], - ((unsigned char *)&my_ninf)[7], - trio_isnan(my_ninf), trio_isinf(my_ninf)); - - return 0; -} -#endif diff --git a/trionan.h b/trionan.h deleted file mode 100644 index eac0e6f16..000000000 --- a/trionan.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 2001 Bjorn Reese - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -#ifndef TRIO_NAN_H -#define TRIO_NAN_H - -#include "triodef.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - TRIO_FP_INFINITE, - TRIO_FP_NAN, - TRIO_FP_NORMAL, - TRIO_FP_SUBNORMAL, - TRIO_FP_ZERO -}; - -/* - * Return NaN (Not-a-Number). - */ -TRIO_PUBLIC double trio_nan TRIO_PROTO((void)); - -/* - * Return positive infinity. - */ -TRIO_PUBLIC double trio_pinf TRIO_PROTO((void)); - -/* - * Return negative infinity. - */ -TRIO_PUBLIC double trio_ninf TRIO_PROTO((void)); - -/* - * Return negative zero. - */ -TRIO_PUBLIC double trio_nzero TRIO_PROTO((TRIO_NOARGS)); - -/* - * If number is a NaN return non-zero, otherwise return zero. - */ -TRIO_PUBLIC int trio_isnan TRIO_PROTO((double number)); - -/* - * If number is positive infinity return 1, if number is negative - * infinity return -1, otherwise return 0. - */ -TRIO_PUBLIC int trio_isinf TRIO_PROTO((double number)); - -/* - * If number is finite return non-zero, otherwise return zero. - */ -#if 0 - /* Temporary fix - these 2 routines not used in libxml */ -TRIO_PUBLIC int trio_isfinite TRIO_PROTO((double number)); - -TRIO_PUBLIC int trio_fpclassify TRIO_PROTO((double number)); -#endif - -TRIO_PUBLIC int trio_signbit TRIO_PROTO((double number)); - -TRIO_PUBLIC int trio_fpclassify_and_signbit TRIO_PROTO((double number, int *is_negative)); - -#ifdef __cplusplus -} -#endif - -#endif /* TRIO_NAN_H */ diff --git a/triop.h b/triop.h deleted file mode 100644 index 6d486f865..000000000 --- a/triop.h +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 2000 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************ - * - * Private functions, types, etc. used for callback functions. - * - * The ref pointer is an opaque type and should remain as such. - * Private data must only be accessible through the getter and - * setter functions. - * - ************************************************************************/ - -#ifndef TRIO_TRIOP_H -#define TRIO_TRIOP_H - -#include "triodef.h" - -#include -#if defined(TRIO_COMPILER_ANCIENT) -# include -#else -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef TRIO_C99 -# define TRIO_C99 1 -#endif -#ifndef TRIO_BSD -# define TRIO_BSD 1 -#endif -#ifndef TRIO_GNU -# define TRIO_GNU 1 -#endif -#ifndef TRIO_MISC -# define TRIO_MISC 1 -#endif -#ifndef TRIO_UNIX98 -# define TRIO_UNIX98 1 -#endif -#ifndef TRIO_MICROSOFT -# define TRIO_MICROSOFT 1 -#endif -#ifndef TRIO_EXTENSION -# define TRIO_EXTENSION 1 -#endif -#ifndef TRIO_WIDECHAR /* Does not work yet. Do not enable */ -# define TRIO_WIDECHAR 0 -#endif -#ifndef TRIO_ERRORS -# define TRIO_ERRORS 1 -#endif - -#ifndef TRIO_MALLOC -# define TRIO_MALLOC(n) malloc(n) -#endif -#ifndef TRIO_REALLOC -# define TRIO_REALLOC(x,n) realloc((x),(n)) -#endif -#ifndef TRIO_FREE -# define TRIO_FREE(x) free(x) -#endif - - -/************************************************************************* - * User-defined specifiers - */ - -typedef int (*trio_callback_t) TRIO_PROTO((trio_pointer_t)); - -trio_pointer_t trio_register TRIO_PROTO((trio_callback_t callback, const char *name)); -void trio_unregister TRIO_PROTO((trio_pointer_t handle)); - -TRIO_CONST char *trio_get_format TRIO_PROTO((trio_pointer_t ref)); -trio_pointer_t trio_get_argument TRIO_PROTO((trio_pointer_t ref)); - -/* Modifiers */ -int trio_get_width TRIO_PROTO((trio_pointer_t ref)); -void trio_set_width TRIO_PROTO((trio_pointer_t ref, int width)); -int trio_get_precision TRIO_PROTO((trio_pointer_t ref)); -void trio_set_precision TRIO_PROTO((trio_pointer_t ref, int precision)); -int trio_get_base TRIO_PROTO((trio_pointer_t ref)); -void trio_set_base TRIO_PROTO((trio_pointer_t ref, int base)); -int trio_get_padding TRIO_PROTO((trio_pointer_t ref)); -void trio_set_padding TRIO_PROTO((trio_pointer_t ref, int is_padding)); -int trio_get_short TRIO_PROTO((trio_pointer_t ref)); /* h */ -void trio_set_shortshort TRIO_PROTO((trio_pointer_t ref, int is_shortshort)); -int trio_get_shortshort TRIO_PROTO((trio_pointer_t ref)); /* hh */ -void trio_set_short TRIO_PROTO((trio_pointer_t ref, int is_short)); -int trio_get_long TRIO_PROTO((trio_pointer_t ref)); /* l */ -void trio_set_long TRIO_PROTO((trio_pointer_t ref, int is_long)); -int trio_get_longlong TRIO_PROTO((trio_pointer_t ref)); /* ll */ -void trio_set_longlong TRIO_PROTO((trio_pointer_t ref, int is_longlong)); -int trio_get_longdouble TRIO_PROTO((trio_pointer_t ref)); /* L */ -void trio_set_longdouble TRIO_PROTO((trio_pointer_t ref, int is_longdouble)); -int trio_get_alternative TRIO_PROTO((trio_pointer_t ref)); /* # */ -void trio_set_alternative TRIO_PROTO((trio_pointer_t ref, int is_alternative)); -int trio_get_alignment TRIO_PROTO((trio_pointer_t ref)); /* - */ -void trio_set_alignment TRIO_PROTO((trio_pointer_t ref, int is_leftaligned)); -int trio_get_spacing TRIO_PROTO((trio_pointer_t ref)); /* TRIO_PROTO((space) */ -void trio_set_spacing TRIO_PROTO((trio_pointer_t ref, int is_space)); -int trio_get_sign TRIO_PROTO((trio_pointer_t ref)); /* + */ -void trio_set_sign TRIO_PROTO((trio_pointer_t ref, int is_showsign)); -int trio_get_quote TRIO_PROTO((trio_pointer_t ref)); /* ' */ -void trio_set_quote TRIO_PROTO((trio_pointer_t ref, int is_quote)); -int trio_get_upper TRIO_PROTO((trio_pointer_t ref)); -void trio_set_upper TRIO_PROTO((trio_pointer_t ref, int is_upper)); -#if TRIO_C99 -int trio_get_largest TRIO_PROTO((trio_pointer_t ref)); /* j */ -void trio_set_largest TRIO_PROTO((trio_pointer_t ref, int is_largest)); -int trio_get_ptrdiff TRIO_PROTO((trio_pointer_t ref)); /* t */ -void trio_set_ptrdiff TRIO_PROTO((trio_pointer_t ref, int is_ptrdiff)); -int trio_get_size TRIO_PROTO((trio_pointer_t ref)); /* z / Z */ -void trio_set_size TRIO_PROTO((trio_pointer_t ref, int is_size)); -#endif - -/* Printing */ -int trio_print_ref TRIO_PROTO((trio_pointer_t ref, const char *format, ...)); -int trio_vprint_ref TRIO_PROTO((trio_pointer_t ref, const char *format, va_list args)); -int trio_printv_ref TRIO_PROTO((trio_pointer_t ref, const char *format, trio_pointer_t *args)); - -void trio_print_int TRIO_PROTO((trio_pointer_t ref, int number)); -void trio_print_uint TRIO_PROTO((trio_pointer_t ref, unsigned int number)); -/* void trio_print_long TRIO_PROTO((trio_pointer_t ref, long number)); */ -/* void trio_print_ulong TRIO_PROTO((trio_pointer_t ref, unsigned long number)); */ -void trio_print_double TRIO_PROTO((trio_pointer_t ref, double number)); -void trio_print_string TRIO_PROTO((trio_pointer_t ref, char *string)); -void trio_print_pointer TRIO_PROTO((trio_pointer_t ref, trio_pointer_t pointer)); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* TRIO_TRIOP_H */ diff --git a/triostr.c b/triostr.c deleted file mode 100644 index 5937a44cf..000000000 --- a/triostr.c +++ /dev/null @@ -1,2112 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -/************************************************************************* - * Include files - */ - -#include -#include -#include -#include -#include -#include "triodef.h" -#include "triostr.h" - -/************************************************************************* - * Definitions - */ - -#if !defined(TRIO_STRING_PUBLIC) -# define TRIO_STRING_PUBLIC TRIO_PUBLIC -#endif -#if !defined(TRIO_STRING_PRIVATE) -# define TRIO_STRING_PRIVATE TRIO_PRIVATE -#endif - -#if !defined(NULL) -# define NULL 0 -#endif -#if !defined(NIL) -# define NIL ((char)0) -#endif -#if !defined(FALSE) -# define FALSE (1 == 0) -# define TRUE (! FALSE) -#endif -#if !defined(BOOLEAN_T) -# define BOOLEAN_T int -#endif - -#ifdef __VMS -# define USE_STRTOD -#elif defined(TRIO_COMPILER_SUPPORTS_C99) -# define USE_STRTOD -# define USE_STRTOF -#elif defined(TRIO_COMPILER_MSVC) -# define USE_STRTOD -#endif - -#if defined(TRIO_PLATFORM_UNIX) -# define USE_STRCASECMP -# define USE_STRNCASECMP -# if defined(TRIO_PLATFORM_SUNOS) -# define USE_SYS_ERRLIST -# else -# define USE_STRERROR -# endif -# if defined(TRIO_PLATFORM_QNX) -# define strcasecmp(x,y) stricmp(x,y) -# define strncasecmp(x,y,n) strnicmp(x,y,n) -# endif -#elif defined(TRIO_PLATFORM_WIN32) -# define USE_STRCASECMP -# if defined(_WIN32_WCE) -# define strcasecmp(x,y) _stricmp(x,y) -# else -# define strcasecmp(x,y) strcmpi(x,y) -# endif -#elif defined(TRIO_PLATFORM_OS400) -# define USE_STRCASECMP -# define USE_STRNCASECMP -# include -#endif - -#if !(defined(TRIO_PLATFORM_SUNOS)) -# define USE_TOLOWER -# define USE_TOUPPER -#endif - -/************************************************************************* - * Structures - */ - -struct _trio_string_t -{ - char *content; - size_t length; - size_t allocated; -}; - -/************************************************************************* - * Constants - */ - -#if !defined(TRIO_MINIMAL) -static TRIO_CONST char rcsid[] = "@(#)$Id$"; -#endif - -/************************************************************************* - * Static String Functions - */ - -#if defined(TRIO_DOCUMENTATION) -# include "doc/doc_static.h" -#endif -/** @addtogroup StaticStrings - @{ -*/ - -/** - Create new string. - - @param size Size of new string. - @return Pointer to string, or NULL if allocation failed. -*/ -TRIO_STRING_PUBLIC char * -trio_create -TRIO_ARGS1((size), - size_t size) -{ - return (char *)TRIO_MALLOC(size); -} - - -/** - Destroy string. - - @param string String to be freed. -*/ -TRIO_STRING_PUBLIC void -trio_destroy -TRIO_ARGS1((string), - char *string) -{ - if (string) - { - TRIO_FREE(string); - } -} - - -/** - Count the number of characters in a string. - - @param string String to measure. - @return Number of characters in @string. -*/ -TRIO_STRING_PUBLIC size_t -trio_length -TRIO_ARGS1((string), - TRIO_CONST char *string) -{ - return strlen(string); -} - - -#if !defined(TRIO_MINIMAL) -/** - Append @p source at the end of @p target. - - @param target Target string. - @param source Source string. - @return Boolean value indicating success or failure. - - @pre @p target must point to a memory chunk with sufficient room to - contain the @p target string and @p source string. - @pre No boundary checking is performed, so insufficient memory will - result in a buffer overrun. - @post @p target will be zero terminated. -*/ -TRIO_STRING_PUBLIC int -trio_append -TRIO_ARGS2((target, source), - char *target, - TRIO_CONST char *source) -{ - assert(target); - assert(source); - - return (strcat(target, source) != NULL); -} -#endif /* !defined(TRIO_MINIMAL) */ - -#if !defined(TRIO_MINIMAL) -/** - Append at most @p max characters from @p source to @p target. - - @param target Target string. - @param max Maximum number of characters to append. - @param source Source string. - @return Boolean value indicating success or failure. - - @pre @p target must point to a memory chuck with sufficient room to - contain the @p target string and the @p source string (at most @p max - characters). - @pre No boundary checking is performed, so insufficient memory will - result in a buffer overrun. - @post @p target will be zero terminated. -*/ -TRIO_STRING_PUBLIC int -trio_append_max -TRIO_ARGS3((target, max, source), - char *target, - size_t max, - TRIO_CONST char *source) -{ - size_t length; - - assert(target); - assert(source); - - length = trio_length(target); - - if (max > length) - { - strncat(target, source, max - length - 1); - } - return TRUE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Determine if a string contains a substring. - - @param string String to be searched. - @param substring String to be found. - @return Boolean value indicating success or failure. -*/ -TRIO_STRING_PUBLIC int -trio_contains -TRIO_ARGS2((string, substring), - TRIO_CONST char *string, - TRIO_CONST char *substring) -{ - assert(string); - assert(substring); - - return (0 != strstr(string, substring)); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Copy @p source to @p target. - - @param target Target string. - @param source Source string. - @return Boolean value indicating success or failure. - - @pre @p target must point to a memory chunk with sufficient room to - contain the @p source string. - @pre No boundary checking is performed, so insufficient memory will - result in a buffer overrun. - @post @p target will be zero terminated. -*/ -TRIO_STRING_PUBLIC int -trio_copy -TRIO_ARGS2((target, source), - char *target, - TRIO_CONST char *source) -{ - assert(target); - assert(source); - - (void)strcpy(target, source); - return TRUE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Copy at most @p max characters from @p source to @p target. - - @param target Target string. - @param max Maximum number of characters to append. - @param source Source string. - @return Boolean value indicating success or failure. - - @pre @p target must point to a memory chunk with sufficient room to - contain the @p source string (at most @p max characters). - @pre No boundary checking is performed, so insufficient memory will - result in a buffer overrun. - @post @p target will be zero terminated. -*/ -TRIO_STRING_PUBLIC int -trio_copy_max -TRIO_ARGS3((target, max, source), - char *target, - size_t max, - TRIO_CONST char *source) -{ - assert(target); - assert(source); - assert(max > 0); /* Includes != 0 */ - - (void)strncpy(target, source, max - 1); - target[max - 1] = (char)0; - return TRUE; -} - - -/* - * TrioDuplicateMax - */ -TRIO_STRING_PRIVATE char * -TrioDuplicateMax -TRIO_ARGS2((source, size), - TRIO_CONST char *source, - size_t size) -{ - char *target; - - assert(source); - - /* Make room for string plus a terminating zero */ - size++; - target = trio_create(size); - if (target) - { - trio_copy_max(target, size, source); - } - return target; -} - - -/** - Duplicate @p source. - - @param source Source string. - @return A copy of the @p source string. - - @post @p target will be zero terminated. -*/ -TRIO_STRING_PUBLIC char * -trio_duplicate -TRIO_ARGS1((source), - TRIO_CONST char *source) -{ - return TrioDuplicateMax(source, trio_length(source)); -} - - -#if !defined(TRIO_MINIMAL) -/** - Duplicate at most @p max characters of @p source. - - @param source Source string. - @param max Maximum number of characters to duplicate. - @return A copy of the @p source string. - - @post @p target will be zero terminated. -*/ -TRIO_STRING_PUBLIC char * -trio_duplicate_max TRIO_ARGS2((source, max), - TRIO_CONST char *source, - size_t max) -{ - size_t length; - - assert(source); - assert(max > 0); - - length = trio_length(source); - if (length > max) - { - length = max; - } - return TrioDuplicateMax(source, length); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Compare if two strings are equal. - - @param first First string. - @param second Second string. - @return Boolean indicating whether the two strings are equal or not. - - Case-insensitive comparison. -*/ -TRIO_STRING_PUBLIC int -trio_equal -TRIO_ARGS2((first, second), - TRIO_CONST char *first, - TRIO_CONST char *second) -{ - assert(first); - assert(second); - - if ((first != NULL) && (second != NULL)) - { -#if defined(USE_STRCASECMP) - return (0 == strcasecmp(first, second)); -#else - while ((*first != NIL) && (*second != NIL)) - { - if (trio_to_upper(*first) != trio_to_upper(*second)) - { - break; - } - first++; - second++; - } - return ((*first == NIL) && (*second == NIL)); -#endif - } - return FALSE; -} - - -/** - Compare if two strings are equal. - - @param first First string. - @param second Second string. - @return Boolean indicating whether the two strings are equal or not. - - Case-sensitive comparison. -*/ -TRIO_STRING_PUBLIC int -trio_equal_case -TRIO_ARGS2((first, second), - TRIO_CONST char *first, - TRIO_CONST char *second) -{ - assert(first); - assert(second); - - if ((first != NULL) && (second != NULL)) - { - return (0 == strcmp(first, second)); - } - return FALSE; -} - - -#if !defined(TRIO_MINIMAL) -/** - Compare if two strings up until the first @p max characters are equal. - - @param first First string. - @param max Maximum number of characters to compare. - @param second Second string. - @return Boolean indicating whether the two strings are equal or not. - - Case-sensitive comparison. -*/ -TRIO_STRING_PUBLIC int -trio_equal_case_max -TRIO_ARGS3((first, max, second), - TRIO_CONST char *first, - size_t max, - TRIO_CONST char *second) -{ - assert(first); - assert(second); - - if ((first != NULL) && (second != NULL)) - { - return (0 == strncmp(first, second, max)); - } - return FALSE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Compare if two strings are equal. - - @param first First string. - @param second Second string. - @return Boolean indicating whether the two strings are equal or not. - - Collating characters are considered equal. -*/ -TRIO_STRING_PUBLIC int -trio_equal_locale -TRIO_ARGS2((first, second), - TRIO_CONST char *first, - TRIO_CONST char *second) -{ - assert(first); - assert(second); - -#if defined(LC_COLLATE) - return (strcoll(first, second) == 0); -#else - return trio_equal(first, second); -#endif -} - - -/** - Compare if two strings up until the first @p max characters are equal. - - @param first First string. - @param max Maximum number of characters to compare. - @param second Second string. - @return Boolean indicating whether the two strings are equal or not. - - Case-insensitive comparison. -*/ -TRIO_STRING_PUBLIC int -trio_equal_max -TRIO_ARGS3((first, max, second), - TRIO_CONST char *first, - size_t max, - TRIO_CONST char *second) -{ - assert(first); - assert(second); - - if ((first != NULL) && (second != NULL)) - { -#if defined(USE_STRNCASECMP) - return (0 == strncasecmp(first, second, max)); -#else - /* Not adequately tested yet */ - size_t cnt = 0; - while ((*first != NIL) && (*second != NIL) && (cnt <= max)) - { - if (trio_to_upper(*first) != trio_to_upper(*second)) - { - break; - } - first++; - second++; - cnt++; - } - return ((cnt == max) || ((*first == NIL) && (*second == NIL))); -#endif - } - return FALSE; -} - - -/** - Provide a textual description of an error code (errno). - - @param error_number Error number. - @return Textual description of @p error_number. -*/ -TRIO_STRING_PUBLIC TRIO_CONST char * -trio_error -TRIO_ARGS1((error_number), - int error_number) -{ -#if defined(USE_STRERROR) - - return strerror(error_number); - -#elif defined(USE_SYS_ERRLIST) - - extern char *sys_errlist[]; - extern int sys_nerr; - - return ((error_number < 0) || (error_number >= sys_nerr)) - ? "unknown" - : sys_errlist[error_number]; - -#else - - return "unknown"; - -#endif -} - - -#if !defined(TRIO_MINIMAL) && !defined(_WIN32_WCE) -/** - Format the date/time according to @p format. - - @param target Target string. - @param max Maximum number of characters to format. - @param format Formatting string. - @param datetime Date/time structure. - @return Number of formatted characters. - - The formatting string accepts the same specifiers as the standard C - function strftime. -*/ -TRIO_STRING_PUBLIC size_t -trio_format_date_max -TRIO_ARGS4((target, max, format, datetime), - char *target, - size_t max, - TRIO_CONST char *format, - TRIO_CONST struct tm *datetime) -{ - assert(target); - assert(format); - assert(datetime); - assert(max > 0); - - return strftime(target, max, format, datetime); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Calculate a hash value for a string. - - @param string String to be calculated on. - @param type Hash function. - @return Calculated hash value. - - @p type can be one of the following - @li @c TRIO_HASH_PLAIN Plain hash function. -*/ -TRIO_STRING_PUBLIC unsigned long -trio_hash -TRIO_ARGS2((string, type), - TRIO_CONST char *string, - int type) -{ - unsigned long value = 0L; - char ch; - - assert(string); - - switch (type) - { - case TRIO_HASH_PLAIN: - while ( (ch = *string++) != NIL ) - { - value *= 31; - value += (unsigned long)ch; - } - break; - default: - assert(FALSE); - break; - } - return value; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Find first occurrence of a character in a string. - - @param string String to be searched. - @param character Character to be found. - @param A pointer to the found character, or NULL if character was not found. - */ -TRIO_STRING_PUBLIC char * -trio_index -TRIO_ARGS2((string, character), - TRIO_CONST char *string, - int character) -{ - assert(string); - - return strchr(string, character); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Find last occurrence of a character in a string. - - @param string String to be searched. - @param character Character to be found. - @param A pointer to the found character, or NULL if character was not found. - */ -TRIO_STRING_PUBLIC char * -trio_index_last -TRIO_ARGS2((string, character), - TRIO_CONST char *string, - int character) -{ - assert(string); - - return strchr(string, character); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Convert the alphabetic letters in the string to lower-case. - - @param target String to be converted. - @return Number of processed characters (converted or not). -*/ -TRIO_STRING_PUBLIC int -trio_lower -TRIO_ARGS1((target), - char *target) -{ - assert(target); - - return trio_span_function(target, target, trio_to_lower); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Compare two strings using wildcards. - - @param string String to be searched. - @param pattern Pattern, including wildcards, to search for. - @return Boolean value indicating success or failure. - - Case-insensitive comparison. - - The following wildcards can be used - @li @c * Match any number of characters. - @li @c ? Match a single character. -*/ -TRIO_STRING_PUBLIC int -trio_match -TRIO_ARGS2((string, pattern), - TRIO_CONST char *string, - TRIO_CONST char *pattern) -{ - assert(string); - assert(pattern); - - for (; ('*' != *pattern); ++pattern, ++string) - { - if (NIL == *string) - { - return (NIL == *pattern); - } - if ((trio_to_upper((int)*string) != trio_to_upper((int)*pattern)) - && ('?' != *pattern)) - { - return FALSE; - } - } - /* two-line patch to prevent *too* much recursiveness: */ - while ('*' == pattern[1]) - pattern++; - - do - { - if ( trio_match(string, &pattern[1]) ) - { - return TRUE; - } - } - while (*string++); - - return FALSE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Compare two strings using wildcards. - - @param string String to be searched. - @param pattern Pattern, including wildcards, to search for. - @return Boolean value indicating success or failure. - - Case-sensitive comparison. - - The following wildcards can be used - @li @c * Match any number of characters. - @li @c ? Match a single character. -*/ -TRIO_STRING_PUBLIC int -trio_match_case -TRIO_ARGS2((string, pattern), - TRIO_CONST char *string, - TRIO_CONST char *pattern) -{ - assert(string); - assert(pattern); - - for (; ('*' != *pattern); ++pattern, ++string) - { - if (NIL == *string) - { - return (NIL == *pattern); - } - if ((*string != *pattern) - && ('?' != *pattern)) - { - return FALSE; - } - } - /* two-line patch to prevent *too* much recursiveness: */ - while ('*' == pattern[1]) - pattern++; - - do - { - if ( trio_match_case(string, &pattern[1]) ) - { - return TRUE; - } - } - while (*string++); - - return FALSE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Execute a function on each character in string. - - @param target Target string. - @param source Source string. - @param Function Function to be executed. - @return Number of processed characters. -*/ -TRIO_STRING_PUBLIC size_t -trio_span_function -TRIO_ARGS3((target, source, Function), - char *target, - TRIO_CONST char *source, - int (*Function) TRIO_PROTO((int))) -{ - size_t count = 0; - - assert(target); - assert(source); - assert(Function); - - while (*source != NIL) - { - *target++ = Function(*source++); - count++; - } - return count; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Search for a substring in a string. - - @param string String to be searched. - @param substring String to be found. - @return Pointer to first occurrence of @p substring in @p string, or NULL - if no match was found. -*/ -TRIO_STRING_PUBLIC char * -trio_substring -TRIO_ARGS2((string, substring), - TRIO_CONST char *string, - TRIO_CONST char *substring) -{ - assert(string); - assert(substring); - - return strstr(string, substring); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Search for a substring in the first @p max characters of a string. - - @param string String to be searched. - @param max Maximum characters to be searched. - @param substring String to be found. - @return Pointer to first occurrence of @p substring in @p string, or NULL - if no match was found. -*/ -TRIO_STRING_PUBLIC char * -trio_substring_max -TRIO_ARGS3((string, max, substring), - TRIO_CONST char *string, - size_t max, - TRIO_CONST char *substring) -{ - size_t count; - size_t size; - char *result = NULL; - - assert(string); - assert(substring); - - size = trio_length(substring); - if (size <= max) - { - for (count = 0; count <= max - size; count++) - { - if (trio_equal_max(substring, size, &string[count])) - { - result = (char *)&string[count]; - break; - } - } - } - return result; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Tokenize string. - - @param string String to be tokenized. - @param tokens String containing list of delimiting characters. - @return Start of new token. - - @warning @p string will be destroyed. -*/ -TRIO_STRING_PUBLIC char * -trio_tokenize -TRIO_ARGS2((string, delimiters), - char *string, - TRIO_CONST char *delimiters) -{ - assert(delimiters); - - return strtok(string, delimiters); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Convert string to floating-point number. - - @param source String to be converted. - @param endp Pointer to end of the converted string. - @return A floating-point number. - - The following Extended Backus-Naur form is used - @verbatim - double ::= [ ] - ( | - | - ) - [ [ ] ] - number ::= 1*( ) - digit ::= ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ) - exponential ::= ( 'e' | 'E' ) - sign ::= ( '-' | '+' ) - decimal_point ::= '.' - @endverbatim -*/ -/* FIXME: Add EBNF for hex-floats */ -TRIO_STRING_PUBLIC trio_long_double_t -trio_to_long_double -TRIO_ARGS2((source, endp), - TRIO_CONST char *source, - char **endp) -{ -#if defined(USE_STRTOLD) - return strtold(source, endp); -#else - int isNegative = FALSE; - int isExponentNegative = FALSE; - trio_long_double_t integer = 0.0; - trio_long_double_t fraction = 0.0; - unsigned long exponent = 0; - trio_long_double_t base; - trio_long_double_t fracdiv = 1.0; - trio_long_double_t value = 0.0; - - /* First try hex-floats */ - if ((source[0] == '0') && ((source[1] == 'x') || (source[1] == 'X'))) - { - base = 16.0; - source += 2; - while (isxdigit((int)*source)) - { - integer *= base; - integer += (isdigit((int)*source) - ? (*source - '0') - : 10 + (trio_to_upper((int)*source) - 'A')); - source++; - } - if (*source == '.') - { - source++; - while (isxdigit((int)*source)) - { - fracdiv /= base; - fraction += fracdiv * (isdigit((int)*source) - ? (*source - '0') - : 10 + (trio_to_upper((int)*source) - 'A')); - source++; - } - if ((*source == 'p') || (*source == 'P')) - { - source++; - if ((*source == '+') || (*source == '-')) - { - isExponentNegative = (*source == '-'); - source++; - } - while (isdigit((int)*source)) - { - exponent *= 10; - exponent += (*source - '0'); - source++; - } - } - } - /* For later use with exponent */ - base = 2.0; - } - else /* Then try normal decimal floats */ - { - base = 10.0; - isNegative = (*source == '-'); - /* Skip sign */ - if ((*source == '+') || (*source == '-')) - source++; - - /* Integer part */ - while (isdigit((int)*source)) - { - integer *= base; - integer += (*source - '0'); - source++; - } - - if (*source == '.') - { - source++; /* skip decimal point */ - while (isdigit((int)*source)) - { - fracdiv /= base; - fraction += (*source - '0') * fracdiv; - source++; - } - } - if ((*source == 'e') - || (*source == 'E') -#if TRIO_MICROSOFT - || (*source == 'd') - || (*source == 'D') -#endif - ) - { - source++; /* Skip exponential indicator */ - isExponentNegative = (*source == '-'); - if ((*source == '+') || (*source == '-')) - source++; - while (isdigit((int)*source)) - { - exponent *= (int)base; - exponent += (*source - '0'); - source++; - } - } - } - - value = integer + fraction; - if (exponent != 0) - { - if (isExponentNegative) - value /= pow(base, (double)exponent); - else - value *= pow(base, (double)exponent); - } - if (isNegative) - value = -value; - - if (endp) - *endp = (char *)source; - return value; -#endif -} - - -/** - Convert string to floating-point number. - - @param source String to be converted. - @param endp Pointer to end of the converted string. - @return A floating-point number. - - See @ref trio_to_long_double. -*/ -TRIO_STRING_PUBLIC double -trio_to_double -TRIO_ARGS2((source, endp), - TRIO_CONST char *source, - char **endp) -{ -#if defined(USE_STRTOD) - return strtod(source, endp); -#else - return (double)trio_to_long_double(source, endp); -#endif -} - -#if !defined(TRIO_MINIMAL) -/** - Convert string to floating-point number. - - @param source String to be converted. - @param endp Pointer to end of the converted string. - @return A floating-point number. - - See @ref trio_to_long_double. -*/ -TRIO_STRING_PUBLIC float -trio_to_float -TRIO_ARGS2((source, endp), - TRIO_CONST char *source, - char **endp) -{ -#if defined(USE_STRTOF) - return strtof(source, endp); -#else - return (float)trio_to_long_double(source, endp); -#endif -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Convert string to signed integer. - - @param string String to be converted. - @param endp Pointer to end of converted string. - @param base Radix number of number. -*/ -TRIO_STRING_PUBLIC long -trio_to_long -TRIO_ARGS3((string, endp, base), - TRIO_CONST char *string, - char **endp, - int base) -{ - assert(string); - assert((base >= 2) && (base <= 36)); - - return strtol(string, endp, base); -} - - -#if !defined(TRIO_MINIMAL) -/** - Convert one alphabetic letter to lower-case. - - @param source The letter to be converted. - @return The converted letter. -*/ -TRIO_STRING_PUBLIC int -trio_to_lower -TRIO_ARGS1((source), - int source) -{ -#if defined(USE_TOLOWER) - - return tolower(source); - -#else - - /* Does not handle locales or non-contiguous alphabetic characters */ - return ((source >= (int)'A') && (source <= (int)'Z')) - ? source - 'A' + 'a' - : source; - -#endif -} -#endif /* !defined(TRIO_MINIMAL) */ - -#if !defined(TRIO_MINIMAL) -/** - Convert string to unsigned integer. - - @param string String to be converted. - @param endp Pointer to end of converted string. - @param base Radix number of number. -*/ -TRIO_STRING_PUBLIC unsigned long -trio_to_unsigned_long -TRIO_ARGS3((string, endp, base), - TRIO_CONST char *string, - char **endp, - int base) -{ - assert(string); - assert((base >= 2) && (base <= 36)); - - return strtoul(string, endp, base); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Convert one alphabetic letter to upper-case. - - @param source The letter to be converted. - @return The converted letter. -*/ -TRIO_STRING_PUBLIC int -trio_to_upper -TRIO_ARGS1((source), - int source) -{ -#if defined(USE_TOUPPER) - - return toupper(source); - -#else - - /* Does not handle locales or non-contiguous alphabetic characters */ - return ((source >= (int)'a') && (source <= (int)'z')) - ? source - 'a' + 'A' - : source; - -#endif -} - -#if !defined(TRIO_MINIMAL) -/** - Convert the alphabetic letters in the string to upper-case. - - @param target The string to be converted. - @return The number of processed characters (converted or not). -*/ -TRIO_STRING_PUBLIC int -trio_upper -TRIO_ARGS1((target), - char *target) -{ - assert(target); - - return trio_span_function(target, target, trio_to_upper); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** @} End of StaticStrings */ - - -/************************************************************************* - * Dynamic String Functions - */ - -#if defined(TRIO_DOCUMENTATION) -# include "doc/doc_dynamic.h" -#endif -/** @addtogroup DynamicStrings - @{ -*/ - -/* - * TrioStringAlloc - */ -TRIO_STRING_PRIVATE trio_string_t * -TrioStringAlloc(TRIO_NOARGS) -{ - trio_string_t *self; - - self = (trio_string_t *)TRIO_MALLOC(sizeof(trio_string_t)); - if (self) - { - self->content = NULL; - self->length = 0; - self->allocated = 0; - } - return self; -} - - -/* - * TrioStringGrow - * - * The size of the string will be increased by 'delta' characters. If - * 'delta' is zero, the size will be doubled. - */ -TRIO_STRING_PRIVATE BOOLEAN_T -TrioStringGrow -TRIO_ARGS2((self, delta), - trio_string_t *self, - size_t delta) -{ - BOOLEAN_T status = FALSE; - char *new_content; - size_t new_size; - - new_size = (delta == 0) - ? ( (self->allocated == 0) ? 1 : self->allocated * 2 ) - : self->allocated + delta; - - new_content = (char *)TRIO_REALLOC(self->content, new_size); - if (new_content) - { - self->content = new_content; - self->allocated = new_size; - status = TRUE; - } - return status; -} - - -#if !defined(TRIO_MINIMAL) -/* - * TrioStringGrowTo - * - * The size of the string will be increased to 'length' plus one characters. - * If 'length' is less than the original size, the original size will be - * used (that is, the size of the string is never decreased). - */ -TRIO_STRING_PRIVATE BOOLEAN_T -TrioStringGrowTo -TRIO_ARGS2((self, length), - trio_string_t *self, - size_t length) -{ - length++; /* Room for terminating zero */ - return (self->allocated < length) - ? TrioStringGrow(self, length - self->allocated) - : TRUE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/** - Create a new dynamic string. - - @param initial_size Initial size of the buffer. - @return Newly allocated dynamic string, or NULL if memory allocation failed. -*/ -TRIO_STRING_PUBLIC trio_string_t * -trio_string_create -TRIO_ARGS1((initial_size), - int initial_size) -{ - trio_string_t *self; - - self = TrioStringAlloc(); - if (self) - { - if (TrioStringGrow(self, - (size_t)((initial_size > 0) ? initial_size : 1))) - { - self->content[0] = (char)0; - self->allocated = initial_size; - } - else - { - trio_string_destroy(self); - self = NULL; - } - } - return self; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Deallocate the dynamic string and its contents. - - @param self Dynamic string -*/ -TRIO_STRING_PUBLIC void -trio_string_destroy -TRIO_ARGS1((self), - trio_string_t *self) -{ - assert(self); - - if (self) - { - trio_destroy(self->content); - TRIO_FREE(self); - } -} - - -#if !defined(TRIO_MINIMAL) -/** - Get a pointer to the content. - - @param self Dynamic string. - @param offset Offset into content. - @return Pointer to the content. - - @p Offset can be zero, positive, or negative. If @p offset is zero, - then the start of the content will be returned. If @p offset is positive, - then a pointer to @p offset number of characters from the beginning of the - content is returned. If @p offset is negative, then a pointer to @p offset - number of characters from the ending of the string, starting at the - terminating zero, is returned. -*/ -TRIO_STRING_PUBLIC char * -trio_string_get -TRIO_ARGS2((self, offset), - trio_string_t *self, - int offset) -{ - char *result = NULL; - - assert(self); - - if (self->content != NULL) - { - if (self->length == 0) - { - (void)trio_string_length(self); - } - if (offset >= 0) - { - if (offset > (int)self->length) - { - offset = self->length; - } - } - else - { - offset += self->length + 1; - if (offset < 0) - { - offset = 0; - } - } - result = &(self->content[offset]); - } - return result; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/** - Extract the content. - - @param self Dynamic String - @return Content of dynamic string. - - The content is removed from the dynamic string. This enables destruction - of the dynamic string without deallocation of the content. -*/ -TRIO_STRING_PUBLIC char * -trio_string_extract -TRIO_ARGS1((self), - trio_string_t *self) -{ - char *result; - - assert(self); - - result = self->content; - /* FIXME: Allocate new empty buffer? */ - self->content = NULL; - self->length = self->allocated = 0; - return result; -} - - -#if !defined(TRIO_MINIMAL) -/** - Set the content of the dynamic string. - - @param self Dynamic String - @param buffer The new content. - - Sets the content of the dynamic string to a copy @p buffer. - An existing content will be deallocated first, if necessary. - - @remark - This function will make a copy of @p buffer. - You are responsible for deallocating @p buffer yourself. -*/ -TRIO_STRING_PUBLIC void -trio_xstring_set -TRIO_ARGS2((self, buffer), - trio_string_t *self, - char *buffer) -{ - assert(self); - - trio_destroy(self->content); - self->content = trio_duplicate(buffer); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/* - * trio_string_size - */ -TRIO_STRING_PUBLIC int -trio_string_size -TRIO_ARGS1((self), - trio_string_t *self) -{ - assert(self); - - return self->allocated; -} - - -/* - * trio_string_terminate - */ -TRIO_STRING_PUBLIC void -trio_string_terminate -TRIO_ARGS1((self), - trio_string_t *self) -{ - trio_xstring_append_char(self, 0); -} - - -#if !defined(TRIO_MINIMAL) -/** - Append the second string to the first. - - @param self Dynamic string to be modified. - @param other Dynamic string to copy from. - @return Boolean value indicating success or failure. -*/ -TRIO_STRING_PUBLIC int -trio_string_append -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - size_t length; - - assert(self); - assert(other); - - length = self->length + other->length; - if (!TrioStringGrowTo(self, length)) - goto error; - trio_copy(&self->content[self->length], other->content); - self->length = length; - return TRUE; - - error: - return FALSE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_append - */ -TRIO_STRING_PUBLIC int -trio_xstring_append -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - size_t length; - - assert(self); - assert(other); - - length = self->length + trio_length(other); - if (!TrioStringGrowTo(self, length)) - goto error; - trio_copy(&self->content[self->length], other); - self->length = length; - return TRUE; - - error: - return FALSE; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/* - * trio_xstring_append_char - */ -TRIO_STRING_PUBLIC int -trio_xstring_append_char -TRIO_ARGS2((self, character), - trio_string_t *self, - char character) -{ - assert(self); - - if ((int)self->length >= trio_string_size(self)) - { - if (!TrioStringGrow(self, 0)) - goto error; - } - self->content[self->length] = character; - self->length++; - return TRUE; - - error: - return FALSE; -} - - -#if !defined(TRIO_MINIMAL) -/** - Search for the first occurrence of second parameter in the first. - - @param self Dynamic string to be modified. - @param other Dynamic string to copy from. - @return Boolean value indicating success or failure. -*/ -TRIO_STRING_PUBLIC int -trio_string_contains -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_contains(self->content, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_contains - */ -TRIO_STRING_PUBLIC int -trio_xstring_contains -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_contains(self->content, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_copy - */ -TRIO_STRING_PUBLIC int -trio_string_copy -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - assert(self); - assert(other); - - self->length = 0; - return trio_string_append(self, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_copy - */ -TRIO_STRING_PUBLIC int -trio_xstring_copy -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - self->length = 0; - return trio_xstring_append(self, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_duplicate - */ -TRIO_STRING_PUBLIC trio_string_t * -trio_string_duplicate -TRIO_ARGS1((other), - trio_string_t *other) -{ - trio_string_t *self; - - assert(other); - - self = TrioStringAlloc(); - if (self) - { - self->content = TrioDuplicateMax(other->content, other->length); - if (self->content) - { - self->length = other->length; - self->allocated = self->length + 1; - } - else - { - self->length = self->allocated = 0; - } - } - return self; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -/* - * trio_xstring_duplicate - */ -TRIO_STRING_PUBLIC trio_string_t * -trio_xstring_duplicate -TRIO_ARGS1((other), - TRIO_CONST char *other) -{ - trio_string_t *self; - - assert(other); - - self = TrioStringAlloc(); - if (self) - { - self->content = TrioDuplicateMax(other, trio_length(other)); - if (self->content) - { - self->length = trio_length(self->content); - self->allocated = self->length + 1; - } - else - { - self->length = self->allocated = 0; - } - } - return self; -} - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_equal - */ -TRIO_STRING_PUBLIC int -trio_string_equal -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_equal(self->content, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_equal - */ -TRIO_STRING_PUBLIC int -trio_xstring_equal -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_equal(self->content, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_equal_max - */ -TRIO_STRING_PUBLIC int -trio_string_equal_max -TRIO_ARGS3((self, max, other), - trio_string_t *self, - size_t max, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_equal_max(self->content, max, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_equal_max - */ -TRIO_STRING_PUBLIC int -trio_xstring_equal_max -TRIO_ARGS3((self, max, other), - trio_string_t *self, - size_t max, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_equal_max(self->content, max, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_equal_case - */ -TRIO_STRING_PUBLIC int -trio_string_equal_case -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_equal_case(self->content, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_equal_case - */ -TRIO_STRING_PUBLIC int -trio_xstring_equal_case -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_equal_case(self->content, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_equal_case_max - */ -TRIO_STRING_PUBLIC int -trio_string_equal_case_max -TRIO_ARGS3((self, max, other), - trio_string_t *self, - size_t max, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_equal_case_max(self->content, max, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_equal_case_max - */ -TRIO_STRING_PUBLIC int -trio_xstring_equal_case_max -TRIO_ARGS3((self, max, other), - trio_string_t *self, - size_t max, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_equal_case_max(self->content, max, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) && !defined(_WIN32_WCE) -/* - * trio_string_format_data_max - */ -TRIO_STRING_PUBLIC size_t -trio_string_format_date_max -TRIO_ARGS4((self, max, format, datetime), - trio_string_t *self, - size_t max, - TRIO_CONST char *format, - TRIO_CONST struct tm *datetime) -{ - assert(self); - - return trio_format_date_max(self->content, max, format, datetime); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_index - */ -TRIO_STRING_PUBLIC char * -trio_string_index -TRIO_ARGS2((self, character), - trio_string_t *self, - int character) -{ - assert(self); - - return trio_index(self->content, character); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_index_last - */ -TRIO_STRING_PUBLIC char * -trio_string_index_last -TRIO_ARGS2((self, character), - trio_string_t *self, - int character) -{ - assert(self); - - return trio_index_last(self->content, character); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_length - */ -TRIO_STRING_PUBLIC int -trio_string_length -TRIO_ARGS1((self), - trio_string_t *self) -{ - assert(self); - - if (self->length == 0) - { - self->length = trio_length(self->content); - } - return self->length; -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_lower - */ -TRIO_STRING_PUBLIC int -trio_string_lower -TRIO_ARGS1((self), - trio_string_t *self) -{ - assert(self); - - return trio_lower(self->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_match - */ -TRIO_STRING_PUBLIC int -trio_string_match -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_match(self->content, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_match - */ -TRIO_STRING_PUBLIC int -trio_xstring_match -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_match(self->content, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_match_case - */ -TRIO_STRING_PUBLIC int -trio_string_match_case -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_match_case(self->content, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_match_case - */ -TRIO_STRING_PUBLIC int -trio_xstring_match_case -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_match_case(self->content, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_substring - */ -TRIO_STRING_PUBLIC char * -trio_string_substring -TRIO_ARGS2((self, other), - trio_string_t *self, - trio_string_t *other) -{ - assert(self); - assert(other); - - return trio_substring(self->content, other->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_xstring_substring - */ -TRIO_STRING_PUBLIC char * -trio_xstring_substring -TRIO_ARGS2((self, other), - trio_string_t *self, - TRIO_CONST char *other) -{ - assert(self); - assert(other); - - return trio_substring(self->content, other); -} -#endif /* !defined(TRIO_MINIMAL) */ - - -#if !defined(TRIO_MINIMAL) -/* - * trio_string_upper - */ -TRIO_STRING_PUBLIC int -trio_string_upper -TRIO_ARGS1((self), - trio_string_t *self) -{ - assert(self); - - return trio_upper(self->content); -} -#endif /* !defined(TRIO_MINIMAL) */ - -/** @} End of DynamicStrings */ diff --git a/triostr.h b/triostr.h deleted file mode 100644 index 0a0e71adb..000000000 --- a/triostr.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************************* - * - * $Id$ - * - * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND - * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. - * - ************************************************************************/ - -#ifndef TRIO_TRIOSTR_H -#define TRIO_TRIOSTR_H - -#include -#include -#include -#include -#include "triodef.h" -#include "triop.h" - -enum { - TRIO_HASH_NONE = 0, - TRIO_HASH_PLAIN, - TRIO_HASH_TWOSIGNED -}; - -#if !defined(TRIO_STRING_PUBLIC) -# if !defined(TRIO_PUBLIC) -# define TRIO_PUBLIC -# endif -# define TRIO_STRING_PUBLIC TRIO_PUBLIC -#endif - -/************************************************************************* - * String functions - */ - -TRIO_STRING_PUBLIC int trio_copy_max TRIO_PROTO((char *target, size_t max, const char *source)); -TRIO_STRING_PUBLIC char *trio_create TRIO_PROTO((size_t size)); -TRIO_STRING_PUBLIC void trio_destroy TRIO_PROTO((char *string)); -TRIO_STRING_PUBLIC char *trio_duplicate TRIO_PROTO((const char *source)); -TRIO_STRING_PUBLIC int trio_equal TRIO_PROTO((const char *first, const char *second)); -TRIO_STRING_PUBLIC int trio_equal_case TRIO_PROTO((const char *first, const char *second)); -TRIO_STRING_PUBLIC int trio_equal_locale TRIO_PROTO((const char *first, const char *second)); -TRIO_STRING_PUBLIC int trio_equal_max TRIO_PROTO((const char *first, size_t max, const char *second)); -TRIO_STRING_PUBLIC TRIO_CONST char *trio_error TRIO_PROTO((int)); -TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string)); -TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp)); -TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base)); -TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp)); -TRIO_STRING_PUBLIC int trio_to_upper TRIO_PROTO((int source)); - -#if !defined(TRIO_MINIMAL) - -TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source)); -TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source)); -TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring)); -TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source)); -TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max)); -TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second)); -#if !defined(_WIN32_WCE) -TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime)); -#endif -TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type)); -TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character)); -TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character)); -TRIO_STRING_PUBLIC int trio_lower TRIO_PROTO((char *target)); -TRIO_STRING_PUBLIC int trio_match TRIO_PROTO((const char *string, const char *pattern)); -TRIO_STRING_PUBLIC int trio_match_case TRIO_PROTO((const char *string, const char *pattern)); -TRIO_STRING_PUBLIC size_t trio_span_function TRIO_PROTO((char *target, const char *source, int (*Function) TRIO_PROTO((int)))); -TRIO_STRING_PUBLIC char *trio_substring TRIO_PROTO((const char *string, const char *substring)); -TRIO_STRING_PUBLIC char *trio_substring_max TRIO_PROTO((const char *string, size_t max, const char *substring)); -TRIO_STRING_PUBLIC float trio_to_float TRIO_PROTO((const char *source, char **endp)); -TRIO_STRING_PUBLIC int trio_to_lower TRIO_PROTO((int source)); -TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_PROTO((const char *source, char **endp, int base)); -TRIO_STRING_PUBLIC char *trio_tokenize TRIO_PROTO((char *string, const char *delimiters)); -TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target)); - -#endif /* !defined(TRIO_MINIMAL) */ - -/************************************************************************* - * Dynamic string functions - */ - -/* - * Opaque type for dynamic strings - */ - -typedef struct _trio_string_t trio_string_t; - -TRIO_STRING_PUBLIC void trio_string_destroy TRIO_PROTO((trio_string_t *self)); -TRIO_STRING_PUBLIC char *trio_string_extract TRIO_PROTO((trio_string_t *self)); -TRIO_STRING_PUBLIC int trio_string_size TRIO_PROTO((trio_string_t *self)); -TRIO_STRING_PUBLIC void trio_string_terminate TRIO_PROTO((trio_string_t *self)); -TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character)); -TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other)); - -#if !defined(TRIO_MINIMAL) - -TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size)); -TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset)); -TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer)); - -TRIO_STRING_PUBLIC int trio_string_append TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC int trio_string_contains TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC int trio_string_copy TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC trio_string_t *trio_string_duplicate TRIO_PROTO((trio_string_t *other)); -TRIO_STRING_PUBLIC int trio_string_equal TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *second)); -TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *other)); -#if !defined(_WIN32_WCE) -TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_PROTO((trio_string_t *self, size_t max, const char *format, const struct tm *datetime)); -#endif -TRIO_STRING_PUBLIC char *trio_string_index TRIO_PROTO((trio_string_t *self, int character)); -TRIO_STRING_PUBLIC char *trio_string_index_last TRIO_PROTO((trio_string_t *self, int character)); -TRIO_STRING_PUBLIC int trio_string_length TRIO_PROTO((trio_string_t *self)); -TRIO_STRING_PUBLIC int trio_string_lower TRIO_PROTO((trio_string_t *self)); -TRIO_STRING_PUBLIC int trio_string_match TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC int trio_string_match_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC char *trio_string_substring TRIO_PROTO((trio_string_t *self, trio_string_t *other)); -TRIO_STRING_PUBLIC int trio_string_upper TRIO_PROTO((trio_string_t *self)); - -TRIO_STRING_PUBLIC int trio_xstring_append TRIO_PROTO((trio_string_t *self, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_PROTO((trio_string_t *self, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_PROTO((trio_string_t *self, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_PROTO((trio_string_t *self, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_PROTO((trio_string_t *self, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_match TRIO_PROTO((trio_string_t *self, const char *other)); -TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_PROTO((trio_string_t *self, const char *other)); -TRIO_STRING_PUBLIC char *trio_xstring_substring TRIO_PROTO((trio_string_t *self, const char *other)); - -#endif /* !defined(TRIO_MINIMAL) */ - -#endif /* TRIO_TRIOSTR_H */ diff --git a/win32/configure.js b/win32/configure.js index 3e496355f..d40f32b64 100644 --- a/win32/configure.js +++ b/win32/configure.js @@ -28,7 +28,6 @@ var verMicroSuffix; var verCvs; var useCvsVer = true; /* Libxml features. */ -var withTrio = false; var withThreads = "native"; var withFtp = true; var withHttp = true; @@ -113,7 +112,6 @@ function usage() txt += "Options can be specified in the form - - dump the memory allocated in the file .memdump - - Get the namespace of a node diff --git a/runxmlconf.c b/runxmlconf.c index bee8bdbaa..18893039d 100644 --- a/runxmlconf.c +++ b/runxmlconf.c @@ -415,7 +415,6 @@ xmlconfTestItem(xmlDocPtr doc, xmlNodePtr cur) { test_log("test %s : %s leaked %d bytes\n", id, filename, final - mem); nb_leaks++; - xmlMemDisplayLast(logfile, final - mem); } nb_tests++; diff --git a/win32/configure.js b/win32/configure.js index d40f32b64..a73cb598b 100644 --- a/win32/configure.js +++ b/win32/configure.js @@ -44,7 +44,6 @@ var withIso8859x = false; var withZlib = false; var withLzma = false; var withDebug = true; -var withMemDebug = false; var withSchemas = true; var withSchematron = true; var withRegExps = true; @@ -128,7 +127,6 @@ function usage() txt += " zlib: Enable zlib support (" + (withZlib? "yes" : "no") + ")\n"; txt += " lzma: Enable lzma support (" + (withLzma? "yes" : "no") + ")\n"; txt += " xml_debug: Enable XML debbugging module (" + (withDebug? "yes" : "no") + ")\n"; - txt += " mem_debug: Enable memory debugger (" + (withMemDebug? "yes" : "no") + ")\n"; txt += " regexps: Enable regular expressions (" + (withRegExps? "yes" : "no") + ")\n"; txt += " modules: Enable module support (" + (withModules? "yes" : "no") + ")\n"; txt += " tree: Enable tree api (" + (withTree? "yes" : "no") + ")\n"; @@ -223,7 +221,6 @@ function discoverVersion() vf.WriteLine("WITH_ZLIB=" + (withZlib? "1" : "0")); vf.WriteLine("WITH_LZMA=" + (withLzma? "1" : "0")); vf.WriteLine("WITH_DEBUG=" + (withDebug? "1" : "0")); - vf.WriteLine("WITH_MEM_DEBUG=" + (withMemDebug? "1" : "0")); vf.WriteLine("WITH_SCHEMAS=" + (withSchemas? "1" : "0")); vf.WriteLine("WITH_SCHEMATRON=" + (withSchematron? "1" : "0")); vf.WriteLine("WITH_REGEXPS=" + (withRegExps? "1" : "0")); @@ -327,8 +324,6 @@ function configureLibxml() of.WriteLine(s.replace(/\@WITH_LZMA\@/, withLzma? "1" : "0")); } else if (s.search(/\@WITH_DEBUG\@/) != -1) { of.WriteLine(s.replace(/\@WITH_DEBUG\@/, withDebug? "1" : "0")); - } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) { - of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0")); } else if (s.search(/\@WITH_SCHEMAS\@/) != -1) { of.WriteLine(s.replace(/\@WITH_SCHEMAS\@/, withSchemas? "1" : "0")); } else if (s.search(/\@WITH_SCHEMATRON\@/) != -1) { @@ -478,8 +473,6 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) { withLzma = strToBool(arg.substring(opt.length + 1, arg.length)); else if (opt == "xml_debug") withDebug = strToBool(arg.substring(opt.length + 1, arg.length)); - else if (opt == "mem_debug") - withMemDebug = strToBool(arg.substring(opt.length + 1, arg.length)); else if (opt == "schemas") withSchemas = strToBool(arg.substring(opt.length + 1, arg.length)); else if (opt == "schematron") @@ -656,7 +649,6 @@ txtOut += " iso8859x support: " + boolToStr(withIso8859x) + "\n"; txtOut += " zlib support: " + boolToStr(withZlib) + "\n"; txtOut += " lzma support: " + boolToStr(withLzma) + "\n"; txtOut += " Debugging module: " + boolToStr(withDebug) + "\n"; -txtOut += " Memory debugging: " + boolToStr(withMemDebug) + "\n"; txtOut += " Regexp support: " + boolToStr(withRegExps) + "\n"; txtOut += " Module support: " + boolToStr(withModules) + "\n"; txtOut += " Tree support: " + boolToStr(withTree) + "\n"; diff --git a/xmllint.c b/xmllint.c index 6cfa0e5b1..1bc119e01 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2987,7 +2987,6 @@ static void showVersion(const char *name) { if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron "); if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules "); if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug "); - if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); if (xmlHasFeature(XML_WITH_LZMA)) fprintf(stderr, "Lzma "); fprintf(stderr, "\n"); diff --git a/xmlmemory.c b/xmlmemory.c index b515f1cc3..a850dfa0c 100644 --- a/xmlmemory.c +++ b/xmlmemory.c @@ -12,18 +12,6 @@ #include #include -/** - * MEM_LIST: - * - * keep track of all allocated blocks for error reporting - * Always build the memory list ! - */ -#ifdef DEBUG_MEMORY_LOCATION -#ifndef MEM_LIST -#define MEM_LIST /* keep a list of all the allocated memory blocks */ -#endif -#endif - #include #include #include @@ -34,62 +22,31 @@ static unsigned long debugMemSize = 0; static unsigned long debugMemBlocks = 0; -static unsigned long debugMaxMemSize = 0; static xmlMutex xmlMemMutex; -void xmlMallocBreakpoint(void); - /************************************************************************ * * * Macros, variables and associated types * * * ************************************************************************/ -#if !defined(LIBXML_THREAD_ENABLED) && !defined(LIBXML_THREAD_ALLOC_ENABLED) -#ifdef xmlMalloc -#undef xmlMalloc -#endif -#ifdef xmlRealloc -#undef xmlRealloc -#endif -#ifdef xmlMemStrdup -#undef xmlMemStrdup -#endif -#endif - /* * Each of the blocks allocated begin with a header containing information */ #define MEMTAG 0x5aa5U -#define MALLOC_TYPE 1 -#define REALLOC_TYPE 2 -#define STRDUP_TYPE 3 -#define MALLOC_ATOMIC_TYPE 4 -#define REALLOC_ATOMIC_TYPE 5 - typedef struct memnod { unsigned int mh_tag; - unsigned int mh_type; - unsigned long mh_number; size_t mh_size; -#ifdef MEM_LIST - struct memnod *mh_next; - struct memnod *mh_prev; -#endif - const char *mh_file; - unsigned int mh_line; -} MEMHDR; - +} MEMHDR; #ifdef SUN4 #define ALIGN_SIZE 16 #else #define ALIGN_SIZE sizeof(double) #endif -#define HDR_SIZE sizeof(MEMHDR) -#define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \ +#define RESERVE_SIZE (((sizeof(MEMHDR) + ALIGN_SIZE - 1) \ / ALIGN_SIZE ) * ALIGN_SIZE) #define MAX_SIZE_T ((size_t)-1) @@ -97,102 +54,21 @@ typedef struct memnod { #define CLIENT_2_HDR(a) ((void *) (((char *) (a)) - RESERVE_SIZE)) #define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE)) - -static unsigned int block=0; -static unsigned int xmlMemStopAtBlock = 0; -static void *xmlMemTraceBlockAt = NULL; -#ifdef MEM_LIST -static MEMHDR *memlist = NULL; -#endif - -static void debugmem_tag_error(void *addr); -#ifdef MEM_LIST -static void debugmem_list_add(MEMHDR *); -static void debugmem_list_delete(MEMHDR *); -#endif -#define Mem_Tag_Err(a) debugmem_tag_error(a); - -#ifndef TEST_POINT -#define TEST_POINT -#endif - -/** - * xmlMallocBreakpoint: - * - * Breakpoint to use in conjunction with xmlMemStopAtBlock. When the block - * number reaches the specified value this function is called. One need to add a breakpoint - * to it to get the context in which the given block is allocated. - */ - -void -xmlMallocBreakpoint(void) { - fprintf(stderr, - "xmlMallocBreakpoint reached on block %d\n", xmlMemStopAtBlock); -} - /** * xmlMallocLoc: * @size: an int specifying the size in byte to allocate. * @file: the file name or NULL * @line: the line number * - * a malloc() equivalent, with logging of the allocation info. + * DEPRECATED: don't use * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ - void * -xmlMallocLoc(size_t size, const char * file, int line) +xmlMallocLoc(size_t size, const char *file ATTRIBUTE_UNUSED, + int line ATTRIBUTE_UNUSED) { - MEMHDR *p; - void *ret; - - xmlInitParser(); - - TEST_POINT - - if (size > (MAX_SIZE_T - RESERVE_SIZE)) { - fprintf(stderr, - "xmlMallocLoc : Unsigned overflow\n"); - return(NULL); - } - - p = (MEMHDR *) malloc(RESERVE_SIZE+size); - - if (!p) { - fprintf(stderr, - "xmlMallocLoc : Out of free space\n"); - return(NULL); - } - p->mh_tag = MEMTAG; - p->mh_size = size; - p->mh_type = MALLOC_TYPE; - p->mh_file = file; - p->mh_line = line; - xmlMutexLock(&xmlMemMutex); - p->mh_number = ++block; - debugMemSize += size; - debugMemBlocks++; - if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; -#ifdef MEM_LIST - debugmem_list_add(p); -#endif - xmlMutexUnlock(&xmlMemMutex); - - if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); - - ret = HDR_2_CLIENT(p); - - if (xmlMemTraceBlockAt == ret) { - fprintf(stderr, - "%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt, - (long unsigned)size); - xmlMallocBreakpoint(); - } - - TEST_POINT - - return(ret); + return(xmlMemMalloc(size)); } /** @@ -201,174 +77,119 @@ xmlMallocLoc(size_t size, const char * file, int line) * @file: the file name or NULL * @line: the line number * - * a malloc() equivalent, with logging of the allocation info. + * DEPRECATED: don't use * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ +void * +xmlMallocAtomicLoc(size_t size, const char *file ATTRIBUTE_UNUSED, + int line ATTRIBUTE_UNUSED) +{ + return(xmlMemMalloc(size)); +} +/** + * xmlMemMalloc: + * @size: an int specifying the size in byte to allocate. + * + * a malloc() equivalent, with logging of the allocation info. + * + * Returns a pointer to the allocated area or NULL in case of lack of memory. + */ void * -xmlMallocAtomicLoc(size_t size, const char * file, int line) +xmlMemMalloc(size_t size) { MEMHDR *p; - void *ret; xmlInitParser(); - TEST_POINT - if (size > (MAX_SIZE_T - RESERVE_SIZE)) { - fprintf(stderr, - "xmlMallocAtomicLoc : Unsigned overflow\n"); - return(NULL); + fprintf(stderr, "xmlMemMalloc: Unsigned overflow\n"); + return(NULL); } - p = (MEMHDR *) malloc(RESERVE_SIZE+size); - + p = (MEMHDR *) malloc(RESERVE_SIZE + size); if (!p) { - fprintf(stderr, - "xmlMallocAtomicLoc : Out of free space\n"); - return(NULL); + fprintf(stderr, "xmlMemMalloc: Out of memory\n"); + return(NULL); } p->mh_tag = MEMTAG; p->mh_size = size; - p->mh_type = MALLOC_ATOMIC_TYPE; - p->mh_file = file; - p->mh_line = line; + xmlMutexLock(&xmlMemMutex); - p->mh_number = ++block; debugMemSize += size; debugMemBlocks++; - if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; -#ifdef MEM_LIST - debugmem_list_add(p); -#endif xmlMutexUnlock(&xmlMemMutex); - if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); - - ret = HDR_2_CLIENT(p); - - if (xmlMemTraceBlockAt == ret) { - fprintf(stderr, - "%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt, - (long unsigned)size); - xmlMallocBreakpoint(); - } - - TEST_POINT - - return(ret); + return(HDR_2_CLIENT(p)); } + /** - * xmlMemMalloc: + * xmlReallocLoc: + * @ptr: the initial memory block pointer * @size: an int specifying the size in byte to allocate. + * @file: the file name or NULL + * @line: the line number * - * a malloc() equivalent, with logging of the allocation info. + * DEPRECATED: don't use * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ - void * -xmlMemMalloc(size_t size) +xmlReallocLoc(void *ptr, size_t size, const char *file ATTRIBUTE_UNUSED, + int line ATTRIBUTE_UNUSED) { - return(xmlMallocLoc(size, "none", 0)); + return(xmlMemRealloc(ptr, size)); } /** - * xmlReallocLoc: + * xmlMemRealloc: * @ptr: the initial memory block pointer * @size: an int specifying the size in byte to allocate. - * @file: the file name or NULL - * @line: the line number * * a realloc() equivalent, with logging of the allocation info. * * Returns a pointer to the allocated area or NULL in case of lack of memory. */ - void * -xmlReallocLoc(void *ptr,size_t size, const char * file, int line) -{ +xmlMemRealloc(void *ptr, size_t size) { MEMHDR *p, *tmp; - unsigned long number; + size_t oldSize; if (ptr == NULL) - return(xmlMallocLoc(size, file, line)); + return(xmlMemMalloc(size)); xmlInitParser(); - TEST_POINT + + if (size > (MAX_SIZE_T - RESERVE_SIZE)) { + fprintf(stderr, "xmlMemRealloc: Unsigned overflow\n"); + return(NULL); + } p = CLIENT_2_HDR(ptr); - number = p->mh_number; - if (xmlMemStopAtBlock == number) xmlMallocBreakpoint(); if (p->mh_tag != MEMTAG) { - Mem_Tag_Err(p); - goto error; + fprintf(stderr, "xmlMemRealloc: Tag error\n"); + return(NULL); } + oldSize = p->mh_size; p->mh_tag = ~MEMTAG; - xmlMutexLock(&xmlMemMutex); - debugMemSize -= p->mh_size; - debugMemBlocks--; -#ifdef MEM_LIST - debugmem_list_delete(p); -#endif - xmlMutexUnlock(&xmlMemMutex); - if (size > (MAX_SIZE_T - RESERVE_SIZE)) { - fprintf(stderr, - "xmlReallocLoc : Unsigned overflow\n"); - return(NULL); - } - - tmp = (MEMHDR *) realloc(p,RESERVE_SIZE+size); + tmp = (MEMHDR *) realloc(p, RESERVE_SIZE + size); if (!tmp) { - free(p); - goto error; + p->mh_tag = MEMTAG; + fprintf(stderr, "xmlMemRealloc: Out of memory\n"); + return(NULL); } p = tmp; - if (xmlMemTraceBlockAt == ptr) { - fprintf(stderr, - "%p : Realloced(%lu -> %lu) Ok\n", - xmlMemTraceBlockAt, (long unsigned)p->mh_size, - (long unsigned)size); - xmlMallocBreakpoint(); - } p->mh_tag = MEMTAG; - p->mh_number = number; - p->mh_type = REALLOC_TYPE; p->mh_size = size; - p->mh_file = file; - p->mh_line = line; + xmlMutexLock(&xmlMemMutex); + debugMemSize -= oldSize; debugMemSize += size; - debugMemBlocks++; - if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; -#ifdef MEM_LIST - debugmem_list_add(p); -#endif xmlMutexUnlock(&xmlMemMutex); - TEST_POINT - return(HDR_2_CLIENT(p)); - -error: - return(NULL); -} - -/** - * xmlMemRealloc: - * @ptr: the initial memory block pointer - * @size: an int specifying the size in byte to allocate. - * - * a realloc() equivalent, with logging of the allocation info. - * - * Returns a pointer to the allocated area or NULL in case of lack of memory. - */ - -void * -xmlMemRealloc(void *ptr,size_t size) { - return(xmlReallocLoc(ptr, size, "none", 0)); } /** @@ -381,53 +202,30 @@ void xmlMemFree(void *ptr) { MEMHDR *p; - char *target; if (ptr == NULL) - return; + return; if (ptr == (void *) -1) { - fprintf(stderr, - "trying to free pointer from freed area\n"); - goto error; - } - - if (xmlMemTraceBlockAt == ptr) { - fprintf(stderr, - "%p : Freed()\n", xmlMemTraceBlockAt); - xmlMallocBreakpoint(); + fprintf(stderr, "xmlMemFree: Pointer from freed area\n"); + return; } - TEST_POINT - - target = (char *) ptr; - p = CLIENT_2_HDR(ptr); if (p->mh_tag != MEMTAG) { - Mem_Tag_Err(p); - goto error; + fprintf(stderr, "xmlMemFree: Tag error\n"); + return; } - if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); p->mh_tag = ~MEMTAG; - memset(target, -1, p->mh_size); + memset(ptr, -1, p->mh_size); + xmlMutexLock(&xmlMemMutex); debugMemSize -= p->mh_size; debugMemBlocks--; -#ifdef MEM_LIST - debugmem_list_delete(p); -#endif xmlMutexUnlock(&xmlMemMutex); free(p); - TEST_POINT - - return; - -error: - fprintf(stderr, - "xmlMemFree(%p) error\n", ptr); - xmlMallocBreakpoint(); return; } @@ -437,78 +235,56 @@ xmlMemFree(void *ptr) * @file: the file name or NULL * @line: the line number * - * a strdup() equivalent, with logging of the allocation info. + * DEPRECATED: don't use * * Returns a pointer to the new string or NULL if allocation error occurred. */ - char * -xmlMemStrdupLoc(const char *str, const char *file, int line) +xmlMemStrdupLoc(const char *str, const char *file ATTRIBUTE_UNUSED, + int line ATTRIBUTE_UNUSED) { + return(xmlMemoryStrdup(str)); +} + +/** + * xmlMemoryStrdup: + * @str: the initial string pointer + * + * a strdup() equivalent, with logging of the allocation info. + * + * Returns a pointer to the new string or NULL if allocation error occurred. + */ +char * +xmlMemoryStrdup(const char *str) { char *s; size_t size = strlen(str) + 1; MEMHDR *p; xmlInitParser(); - TEST_POINT if (size > (MAX_SIZE_T - RESERVE_SIZE)) { - fprintf(stderr, - "xmlMemStrdupLoc : Unsigned overflow\n"); - return(NULL); + fprintf(stderr, "xmlMemoryStrdup: Unsigned overflow\n"); + return(NULL); } - p = (MEMHDR *) malloc(RESERVE_SIZE+size); + p = (MEMHDR *) malloc(RESERVE_SIZE + size); if (!p) { - goto error; + fprintf(stderr, "xmlMemoryStrdup: Out of memory\n"); + return(NULL); } p->mh_tag = MEMTAG; p->mh_size = size; - p->mh_type = STRDUP_TYPE; - p->mh_file = file; - p->mh_line = line; + xmlMutexLock(&xmlMemMutex); - p->mh_number = ++block; debugMemSize += size; debugMemBlocks++; - if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize; -#ifdef MEM_LIST - debugmem_list_add(p); -#endif xmlMutexUnlock(&xmlMemMutex); s = (char *) HDR_2_CLIENT(p); - if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint(); - - strcpy(s,str); - - TEST_POINT - - if (xmlMemTraceBlockAt == s) { - fprintf(stderr, - "%p : Strdup() Ok\n", xmlMemTraceBlockAt); - xmlMallocBreakpoint(); - } + memcpy(s, str, size); return(s); - -error: - return(NULL); -} - -/** - * xmlMemoryStrdup: - * @str: the initial string pointer - * - * a strdup() equivalent, with logging of the allocation info. - * - * Returns a pointer to the new string or NULL if allocation error occurred. - */ - -char * -xmlMemoryStrdup(const char *str) { - return(xmlMemStrdupLoc(str, "none", 0)); } /** @@ -565,256 +341,47 @@ xmlMemBlocks(void) { /** * xmlMemDisplayLast: - * @fp: a FILE descriptor used as the output file, if NULL, the result is - * written to the file .memorylist + * @fp: a FILE descriptor * @nbBytes: the amount of memory to dump * - * the last nbBytes of memory allocated and not freed, useful for dumping - * the memory left allocated between two places at runtime. + * DEPRECATED: This feature was removed. */ - void -xmlMemDisplayLast(FILE *fp, long nbBytes) +xmlMemDisplayLast(FILE *fp ATTRIBUTE_UNUSED, long nbBytes ATTRIBUTE_UNUSED) { -#ifdef MEM_LIST - MEMHDR *p; - unsigned idx; - int nb = 0; -#endif - FILE *old_fp = fp; - - if (nbBytes <= 0) - return; - - if (fp == NULL) { - fp = fopen(".memorylist", "w"); - if (fp == NULL) - return; - } - -#ifdef MEM_LIST - fprintf(fp," Last %li MEMORY ALLOCATED : %lu, MAX was %lu\n", - nbBytes, debugMemSize, debugMaxMemSize); - fprintf(fp,"BLOCK NUMBER SIZE TYPE\n"); - idx = 0; - xmlMutexLock(&xmlMemMutex); - p = memlist; - while ((p) && (nbBytes > 0)) { - fprintf(fp,"%-5u %6lu %6lu ",idx++,p->mh_number, - (unsigned long)p->mh_size); - switch (p->mh_type) { - case STRDUP_TYPE:fprintf(fp,"strdup() in ");break; - case MALLOC_TYPE:fprintf(fp,"malloc() in ");break; - case REALLOC_TYPE:fprintf(fp,"realloc() in ");break; - case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break; - case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break; - default: - fprintf(fp,"Unknown memory block, may be corrupted"); - xmlMutexUnlock(&xmlMemMutex); - if (old_fp == NULL) - fclose(fp); - return; - } - if (p->mh_file != NULL) fprintf(fp,"%s(%u)", p->mh_file, p->mh_line); - if (p->mh_tag != MEMTAG) - fprintf(fp," INVALID"); - nb++; - - fprintf(fp,"\n"); - nbBytes -= (unsigned long)p->mh_size; - p = p->mh_next; - } - xmlMutexUnlock(&xmlMemMutex); -#else - fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n"); -#endif - if (old_fp == NULL) - fclose(fp); } /** * xmlMemDisplay: - * @fp: a FILE descriptor used as the output file, if NULL, the result is - * written to the file .memorylist + * @fp: a FILE descriptor * - * show in-extenso the memory blocks allocated + * DEPRECATED: This feature was removed. */ - void -xmlMemDisplay(FILE *fp) -{ -#ifdef MEM_LIST - MEMHDR *p; - unsigned idx; - int nb = 0; - time_t currentTime; - char buf[500]; - struct tm * tstruct; -#endif - FILE *old_fp = fp; - - if (fp == NULL) { - fp = fopen(".memorylist", "w"); - if (fp == NULL) - return; - } - -#ifdef MEM_LIST - currentTime = time(NULL); - tstruct = localtime(¤tTime); - strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct); - fprintf(fp," %s\n\n", buf); - - - fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n", - debugMemSize, debugMaxMemSize); - fprintf(fp,"BLOCK NUMBER SIZE TYPE\n"); - idx = 0; - xmlMutexLock(&xmlMemMutex); - p = memlist; - while (p) { - fprintf(fp,"%-5u %6lu %6lu ",idx++,p->mh_number, - (unsigned long)p->mh_size); - switch (p->mh_type) { - case STRDUP_TYPE:fprintf(fp,"strdup() in ");break; - case MALLOC_TYPE:fprintf(fp,"malloc() in ");break; - case REALLOC_TYPE:fprintf(fp,"realloc() in ");break; - case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break; - case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break; - default: - fprintf(fp,"Unknown memory block, may be corrupted"); - xmlMutexUnlock(&xmlMemMutex); - if (old_fp == NULL) - fclose(fp); - return; - } - if (p->mh_file != NULL) fprintf(fp,"%s(%u)", p->mh_file, p->mh_line); - if (p->mh_tag != MEMTAG) - fprintf(fp," INVALID"); - nb++; - - fprintf(fp,"\n"); - p = p->mh_next; - } - xmlMutexUnlock(&xmlMemMutex); -#else - fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n"); -#endif - if (old_fp == NULL) - fclose(fp); -} - -#ifdef MEM_LIST - -static void debugmem_list_add(MEMHDR *p) -{ - p->mh_next = memlist; - p->mh_prev = NULL; - if (memlist) memlist->mh_prev = p; - memlist = p; -} - -static void debugmem_list_delete(MEMHDR *p) -{ - if (p->mh_next) - p->mh_next->mh_prev = p->mh_prev; - if (p->mh_prev) - p->mh_prev->mh_next = p->mh_next; - else memlist = p->mh_next; -} - -#endif - -/* - * debugmem_tag_error: - * - * internal error function. - */ - -static void debugmem_tag_error(void *p) +xmlMemDisplay(FILE *fp ATTRIBUTE_UNUSED) { - fprintf(stderr, - "Memory tag error occurs :%p \n\t bye\n", p); -#ifdef MEM_LIST - if (stderr) - xmlMemDisplay(stderr); -#endif } -#ifdef MEM_LIST -static FILE *xmlMemoryDumpFile = NULL; -#endif - /** * xmlMemShow: - * @fp: a FILE descriptor used as the output file + * @fp: a FILE descriptor * @nr: number of entries to dump * - * show a show display of the memory allocated, and dump - * the @nr last allocated areas which were not freed + * DEPRECATED: This feature was removed. */ - void -xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED) +xmlMemShow(FILE *fp ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { -#ifdef MEM_LIST - MEMHDR *p; -#endif - - if (fp != NULL) - fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n", - debugMemSize, debugMaxMemSize); -#ifdef MEM_LIST - xmlMutexLock(&xmlMemMutex); - if (nr > 0) { - fprintf(fp,"NUMBER SIZE TYPE WHERE\n"); - p = memlist; - while ((p) && nr > 0) { - fprintf(fp,"%6lu %6lu ",p->mh_number,(unsigned long)p->mh_size); - switch (p->mh_type) { - case STRDUP_TYPE:fprintf(fp,"strdup() in ");break; - case MALLOC_TYPE:fprintf(fp,"malloc() in ");break; - case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break; - case REALLOC_TYPE:fprintf(fp,"realloc() in ");break; - case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break; - default:fprintf(fp," ??? in ");break; - } - if (p->mh_file != NULL) - fprintf(fp,"%s(%u)", p->mh_file, p->mh_line); - if (p->mh_tag != MEMTAG) - fprintf(fp," INVALID"); - fprintf(fp,"\n"); - nr--; - p = p->mh_next; - } - } - xmlMutexUnlock(&xmlMemMutex); -#endif /* MEM_LIST */ } /** * xmlMemoryDump: * - * Dump in-extenso the memory blocks allocated to the file .memorylist + * DEPRECATED: This feature was removed. */ - void xmlMemoryDump(void) { -#ifdef MEM_LIST - FILE *dump; - - if (debugMaxMemSize == 0) - return; - dump = fopen(".memdump", "w"); - if (dump == NULL) - xmlMemoryDumpFile = stderr; - else xmlMemoryDumpFile = dump; - - xmlMemDisplay(xmlMemoryDumpFile); - - if (dump != NULL) fclose(dump); -#endif /* MEM_LIST */ } @@ -844,18 +411,7 @@ xmlInitMemory(void) { */ void xmlInitMemoryInternal(void) { - char *breakpoint; - xmlInitMutex(&xmlMemMutex); - - breakpoint = getenv("XML_MEM_BREAKPOINT"); - if (breakpoint != NULL) { - sscanf(breakpoint, "%ud", &xmlMemStopAtBlock); - } - breakpoint = getenv("XML_MEM_TRACE"); - if (breakpoint != NULL) { - sscanf(breakpoint, "%p", &xmlMemTraceBlockAt); - } - + xmlInitMutex(&xmlMemMutex); } /** From d381e5de4a8dc27983361d3ab3f45531cc5a2a6f Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 28 Apr 2024 21:14:32 +0200 Subject: [PATCH 416/504] doc: Move doc/examples to example --- .gitignore | 1 - .gitlab-ci.yml | 2 - Makefile.am | 1 - configure.ac | 2 +- doc/Makefile.am | 3 +- doc/examples/Makefile.am | 101 ---- doc/examples/examples.xml | 723 ------------------------- doc/examples/examples.xsl | 112 ---- doc/examples/index.html | 468 ---------------- doc/examples/index.py | 290 ---------- doc/examples/meson.build | 59 -- doc/meson.build | 1 - {doc/examples => example}/.gitignore | 1 + example/Makefile.am | 42 +- {doc/examples => example}/io1.c | 0 {doc/examples => example}/io2.c | 0 example/meson.build | 33 +- {doc/examples => example}/parse1.c | 0 {doc/examples => example}/parse2.c | 0 {doc/examples => example}/parse3.c | 0 {doc/examples => example}/parse4.c | 0 {doc/examples => example}/reader1.c | 0 {doc/examples => example}/reader2.c | 0 {doc/examples => example}/reader3.c | 0 {doc/examples => example}/reader4.c | 0 {doc/examples => example}/test1.xml | 0 {doc/examples => example}/test2.xml | 0 {doc/examples => example}/test3.xml | 0 {doc/examples => example}/testWriter.c | 0 {doc/examples => example}/tree1.c | 0 {doc/examples => example}/tree2.c | 0 {doc/examples => example}/xpath1.c | 0 {doc/examples => example}/xpath2.c | 0 33 files changed, 68 insertions(+), 1771 deletions(-) delete mode 100644 doc/examples/Makefile.am delete mode 100644 doc/examples/examples.xml delete mode 100644 doc/examples/examples.xsl delete mode 100644 doc/examples/index.html delete mode 100755 doc/examples/index.py delete mode 100644 doc/examples/meson.build rename {doc/examples => example}/.gitignore (92%) rename {doc/examples => example}/io1.c (100%) rename {doc/examples => example}/io2.c (100%) rename {doc/examples => example}/parse1.c (100%) rename {doc/examples => example}/parse2.c (100%) rename {doc/examples => example}/parse3.c (100%) rename {doc/examples => example}/parse4.c (100%) rename {doc/examples => example}/reader1.c (100%) rename {doc/examples => example}/reader2.c (100%) rename {doc/examples => example}/reader3.c (100%) rename {doc/examples => example}/reader4.c (100%) rename {doc/examples => example}/test1.xml (100%) rename {doc/examples => example}/test2.xml (100%) rename {doc/examples => example}/test3.xml (100%) rename {doc/examples => example}/testWriter.c (100%) rename {doc/examples => example}/tree1.c (100%) rename {doc/examples => example}/tree2.c (100%) rename {doc/examples => example}/xpath1.c (100%) rename {doc/examples => example}/xpath2.c (100%) diff --git a/.gitignore b/.gitignore index 556671114..4b2f754dd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ *.pyc # Executables -/example/gjobread /xmlcatalog /xmllint diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7fb9c8c2b..a4e8c0eaf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -290,8 +290,6 @@ pages: script: - mkdir -p public - cp -r doc/devhelp doc/tutorial doc/xmllint.html doc/xmlcatalog.html public - - mkdir -p public/examples - - cp doc/examples/*.html doc/examples/*.c public/examples artifacts: paths: - public diff --git a/Makefile.am b/Makefile.am index 3e8de7b84..727185e43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -380,7 +380,6 @@ DISTCLEANFILES = COPYING missing.lst EXTRA_DIST = Copyright check-xml-test-suite.py gentest.py \ check-relaxng-test-suite.py check-relaxng-test-suite2.py \ check-xsddata-test-suite.py check-xinclude-test-suite.py \ - example/Makefile.am example/gjobread.c example/gjobs.xml \ libxml2-config.cmake.in autogen.sh \ libxml.h \ genUnicode.py \ diff --git a/configure.ac b/configure.ac index 6d05f6c72..fc0a9b3db 100644 --- a/configure.ac +++ b/configure.ac @@ -1158,7 +1158,7 @@ RELDATE=`date +'%a %b %e %Y'` AC_SUBST(RELDATE) # keep on one line for cygwin c.f. #130896 -AC_CONFIG_FILES([Makefile include/Makefile include/libxml/Makefile include/private/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc libxml-2.0-uninstalled.pc libxml2-config.cmake]) +AC_CONFIG_FILES([Makefile include/Makefile include/libxml/Makefile include/private/Makefile doc/Makefile doc/devhelp/Makefile example/Makefile fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc libxml-2.0-uninstalled.pc libxml2-config.cmake]) AC_CONFIG_FILES([python/setup.py], [chmod +x python/setup.py]) AC_CONFIG_FILES([xml2-config], [chmod +x xml2-config]) AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am index 1b992417b..577bb34ab 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = . devhelp examples +SUBDIRS = . devhelp nobase_dist_doc_DATA = \ tutorial/apa.html \ @@ -72,7 +72,6 @@ rebuild: cd $(srcdir) && $(XSLTPROC) --nonet xmlcatalog.xml cd $(srcdir) && $(XSLTPROC) --nonet -o xmlcatalog.html $(DOCBOOK_HTML) xmlcatalog.xml cd devhelp && $(MAKE) rebuild - cd examples && $(MAKE) rebuild cd .. && $(MAKE) rebuild_testapi .PHONY: rebuild diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am deleted file mode 100644 index 3b82da6ba..000000000 --- a/doc/examples/Makefile.am +++ /dev/null @@ -1,101 +0,0 @@ -AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -LDADD = $(top_builddir)/libxml2.la - -rebuild: - cd $(srcdir) && $(PYTHON) index.py - $(MAKE) Makefile - cd $(srcdir) && xsltproc examples.xsl examples.xml - -cd $(srcdir) && xmllint --valid --noout index.html - -.PHONY: rebuild - -install-data-local: - $(MKDIR_P) $(DESTDIR)$(docdir)/examples - -$(INSTALL) -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(DESTDIR)$(docdir)/examples/ - -uninstall-local: - rm -f $(DESTDIR)$(docdir)/examples/*.c - rm -f $(DESTDIR)$(docdir)/examples/*.html - -rmdir $(DESTDIR)$(docdir)/examples - -clean-local: - test -f Makefile.am || rm -f test?.xml - -EXTRA_DIST = \ - examples.xml \ - examples.xsl \ - index.html \ - index.py \ - test1.xml \ - test2.xml \ - test3.xml \ - meson.build - -check_PROGRAMS = \ - io1 \ - io2 \ - parse1 \ - parse2 \ - parse3 \ - parse4 \ - reader1 \ - reader2 \ - reader3 \ - reader4 \ - testWriter \ - tree1 \ - tree2 \ - xpath1 \ - xpath2 - -io1_SOURCES = io1.c - -io2_SOURCES = io2.c - -parse1_SOURCES = parse1.c - -parse2_SOURCES = parse2.c - -parse3_SOURCES = parse3.c - -parse4_SOURCES = parse4.c - -reader1_SOURCES = reader1.c - -reader2_SOURCES = reader2.c - -reader3_SOURCES = reader3.c - -reader4_SOURCES = reader4.c - -testWriter_SOURCES = testWriter.c - -tree1_SOURCES = tree1.c - -tree2_SOURCES = tree2.c - -xpath1_SOURCES = xpath1.c - -xpath2_SOURCES = xpath2.c - -valgrind: - $(MAKE) CHECKER='valgrind' check - -check-local: - @test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml . - @(echo '## examples regression tests') - @$(CHECKER) ./io1 >/dev/null - @$(CHECKER) ./io2 >/dev/null - @$(CHECKER) ./parse1 test1.xml - @$(CHECKER) ./parse2 test2.xml - @$(CHECKER) ./parse3 - @$(CHECKER) ./parse4 test3.xml - @$(CHECKER) ./reader1 test2.xml >/dev/null - @$(CHECKER) ./reader2 test2.xml >/dev/null - @$(CHECKER) ./reader3 >/dev/null - @$(CHECKER) ./reader4 test1.xml test2.xml test3.xml >/dev/null - @$(CHECKER) ./testWriter - @$(CHECKER) ./tree1 test2.xml >/dev/null - @$(CHECKER) ./tree2 >/dev/null - @$(CHECKER) ./xpath1 test3.xml '//child2' >/dev/null - @$(CHECKER) ./xpath2 test3.xml '//discarded' discarded >/dev/null diff --git a/doc/examples/examples.xml b/doc/examples/examples.xml deleted file mode 100644 index 0cf0f2b86..000000000 --- a/doc/examples/examples.xml +++ /dev/null @@ -1,723 +0,0 @@ - - - Example of custom Input/Output - Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way. - io1 - io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res - Daniel Veillard - see Copyright for the status of this software. -
InputOutput
- - <libxml/parser.h> - <libxml/tree.h> - <libxml/xinclude.h> - <libxml/xmlIO.h> - - - - - - - - - - -
- - Output to char buffer - Demonstrate the use of xmlDocDumpMemory to output document to a character buffer - io2 - io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res - John Fleck - see Copyright for the status of this software. -
InputOutput
- - <libxml/parser.h> - - - - - - - - - - - - -
- - Parse an XML file to a tree and free it - Demonstrate the use of xmlReadFile() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree - parse1 test1.xml - parse1 test1.xml - Daniel Veillard - see Copyright for the status of this software. -
Parsing
- - <libxml/parser.h> - <libxml/tree.h> - - - - - - - -
- - Parse and validate an XML file to a tree and free the result - Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree. - parse2 test2.xml - parse2 test2.xml - Daniel Veillard - see Copyright for the status of this software. -
Parsing
- - <libxml/parser.h> - <libxml/tree.h> - - - - - - - - - - - -
- - Parse an XML document in memory to a tree and free it - Demonstrate the use of xmlReadMemory() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree - parse3 - parse3 - Daniel Veillard - see Copyright for the status of this software. -
Parsing
- - <libxml/parser.h> - <libxml/tree.h> - - - - - - - -
- - Parse an XML document chunk by chunk to a tree and free it - Demonstrate the use of xmlCreatePushParserCtxt() and xmlParseChunk() to read an XML file progressively into a tree and xmlFreeDoc() to free the resulting tree - parse4 test3.xml - parse4 test3.xml - Daniel Veillard - see Copyright for the status of this software. -
Parsing
- - <libxml/parser.h> - <libxml/tree.h> - - - - - - - - - - -
- - Parse an XML file with an xmlReader - Demonstrate the use of xmlReaderForFile() to parse an XML file and dump the information about the nodes found in the process. (Note that the XMLReader functions require libxml2 version later than 2.6.) - reader1 <filename> - reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res - Daniel Veillard - see Copyright for the status of this software. -
xmlReader
- - <libxml/xmlreader.h> - - - - - - - - - - - - - - - -
- - Parse and validate an XML file with an xmlReader - Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.) - reader2 <valid_xml_filename> - reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res - Daniel Veillard - see Copyright for the status of this software. -
xmlReader
- - <libxml/parser.h> - <libxml/xmlreader.h> - - - - - - - - - - - - - - - - - - -
- - Show how to extract subdocuments with xmlReader - Demonstrate the use of xmlTextReaderPreservePattern() to parse an XML file with the xmlReader while collecting only some subparts of the document. (Note that the XMLReader functions require libxml2 version later than 2.6.) - reader3 - reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res - Daniel Veillard - see Copyright for the status of this software. -
xmlReader
- - <libxml/xmlreader.h> - - - - - - - - - - -
- - Parse multiple XML files reusing an xmlReader - Demonstrate the use of xmlReaderForFile() and xmlReaderNewFile to parse XML files while reusing the reader object and parser context. (Note that the XMLReader functions require libxml2 version later than 2.6.) - reader4 <filename> [ filename ... ] - reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res - Graham Bennett - see Copyright for the status of this software. -
xmlReader
- - <libxml/xmlreader.h> - - - - - - - - - -
- - use various APIs for the xmlWriter - tests a number of APIs for the xmlWriter, especially the various methods to write to a filename, to a memory buffer, to a new document, or to a subtree. It shows how to do encoding string conversions too. The resulting documents are then serialized. - testWriter - testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done - Alfred Mickautsch - see Copyright for the status of this software. -
xmlWriter
- - <libxml/encoding.h> - <libxml/parser.h> - <libxml/xmlwriter.h> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Navigates a tree to print element names - Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order. - tree1 filename_or_URL - tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res - Dodji Seketeli - see Copyright for the status of this software. -
Tree
- - <libxml/parser.h> - <libxml/tree.h> - - - - - - -
- - Creates a tree - Shows how to create document, nodes and dump it to stdout or file. - tree2 <filename> -Default output: stdout - tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res - Lucas Brasilino <brasilino@recife.pe.gov.br> - see Copyright for the status of this software -
Tree
- - <libxml/parser.h> - <libxml/tree.h> - - - - - - - - - - - - -
- - Evaluate XPath expression and prints result node set. - Shows how to evaluate XPath expression and register known namespaces in XPath context. - xpath1 <xml-file> <xpath-expr> [<known-ns-list>] - xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res - Aleksey Sanin - see Copyright for the status of this software. -
XPath
- - <libxml/parser.h> - <libxml/tree.h> - <libxml/xpath.h> - <libxml/xpathInternals.h> - - - - - - - - - - - - - - - - - - - -
- - Load a document, locate subelements with XPath, modify said elements and save the resulting document. - Shows how to make a full round-trip from a load/edit/save - xpath2 <xml-file> <xpath-expr> <new-value> - xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res - Aleksey Sanin and Daniel Veillard - see Copyright for the status of this software. -
XPath
- - <libxml/parser.h> - <libxml/tree.h> - <libxml/xpath.h> - <libxml/xpathInternals.h> - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
-
- - -
-
- - -
-
- - - - -
-
- -
-
-
diff --git a/doc/examples/examples.xsl b/doc/examples/examples.xsl deleted file mode 100644 index c515408d8..000000000 --- a/doc/examples/examples.xsl +++ /dev/null @@ -1,112 +0,0 @@ - - - - https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2- - - - - -
  • -
    - - - - - -
  • line : Type from
  • -
    - - - - - -
  • line : Function from
  • -
    - - - - - -
  • line : Macro from
  • -
    - - - -

    :

    -

    -

    Includes:

    -
      - - - - -
    -

    Uses:

    -
      - - - - -
    -

    Usage:

    -

    -

    Author:

    -
    - - -
  • :

    -
      - - - -
    • :
    • -
      -
    -
  • -
    - - -

    The examples are stored per section depending on the main focus - of the example:

    -
      - - - - -
    -

    Getting the compilation options and libraries dependencies needed -to generate binaries from the examples is best done on Linux/Unix by using -the xml2-config script which should have been installed as part of make -install step or when installing the libxml2 development package:

    -
    gcc -o example `xml2-config --cflags` example.c `xml2-config --libs`
    -
    - - - - -

    Examples

    - -
    -
    - - - Libxml2 set of examples - - - - - <xsl:value-of select="$title"/> - - - -

    - - - - -
    -
    - -
    diff --git a/doc/examples/index.html b/doc/examples/index.html deleted file mode 100644 index 146940306..000000000 --- a/doc/examples/index.html +++ /dev/null @@ -1,468 +0,0 @@ - - - - - Libxml2 set of examples - - -

    Libxml2 set of examples

    -

    The examples are stored per section depending on the main focus - of the example:

    -
      -
    • -

      xmlWriter :

      - -
    • -
    • -

      InputOutput :

      -
        -
      • io1.c: Example of custom Input/Output
      • -
      • io2.c: Output to char buffer
      • -
      -
    • -
    • -

      Tree :

      -
        -
      • tree1.c: Navigates a tree to print element names
      • -
      • tree2.c: Creates a tree
      • -
      -
    • -
    • -

      XPath :

      -
        -
      • xpath1.c: Evaluate XPath expression and prints result node set.
      • -
      • xpath2.c: Load a document, locate subelements with XPath, modify said elements and save the resulting document.
      • -
      -
    • -
    • -

      Parsing :

      -
        -
      • parse1.c: Parse an XML file to a tree and free it
      • -
      • parse2.c: Parse and validate an XML file to a tree and free the result
      • -
      • parse3.c: Parse an XML document in memory to a tree and free it
      • -
      • parse4.c: Parse an XML document chunk by chunk to a tree and free it
      • -
      -
    • -
    • -

      xmlReader :

      -
        -
      • reader1.c: Parse an XML file with an xmlReader
      • -
      • reader2.c: Parse and validate an XML file with an xmlReader
      • -
      • reader3.c: Show how to extract subdocuments with xmlReader
      • -
      • reader4.c: Parse multiple XML files reusing an xmlReader
      • -
      -
    • -
    -

    Getting the compilation options and libraries dependencies needed -to generate binaries from the examples is best done on Linux/Unix by using -the xml2-config script which should have been installed as part of make -install step or when installing the libxml2 development package:

    -
    gcc -o example `xml2-config --cflags` example.c `xml2-config --libs`
    -

    InputOutput Examples

    -

    io1.c: Example of custom Input/Output

    -

    Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way.

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    io1

    -

    Author: Daniel Veillard

    -

    io2.c: Output to char buffer

    -

    Demonstrate the use of xmlDocDumpMemory to output document to a character buffer

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    io2

    -

    Author: John Fleck

    -

    Parsing Examples

    -

    parse1.c: Parse an XML file to a tree and free it

    -

    Demonstrate the use of xmlReadFile() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    parse1 test1.xml

    -

    Author: Daniel Veillard

    -

    parse2.c: Parse and validate an XML file to a tree and free the result

    -

    Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    parse2 test2.xml

    -

    Author: Daniel Veillard

    -

    parse3.c: Parse an XML document in memory to a tree and free it

    -

    Demonstrate the use of xmlReadMemory() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    parse3

    -

    Author: Daniel Veillard

    -

    parse4.c: Parse an XML document chunk by chunk to a tree and free it

    -

    Demonstrate the use of xmlCreatePushParserCtxt() and xmlParseChunk() to read an XML file progressively into a tree and xmlFreeDoc() to free the resulting tree

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    parse4 test3.xml

    -

    Author: Daniel Veillard

    -

    Tree Examples

    -

    tree1.c: Navigates a tree to print element names

    -

    Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    tree1 filename_or_URL

    -

    Author: Dodji Seketeli

    -

    tree2.c: Creates a tree

    -

    Shows how to create document, nodes and dump it to stdout or file.

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    tree2 <filename> -Default output: stdout

    -

    Author: Lucas Brasilino <brasilino@recife.pe.gov.br>

    -

    XPath Examples

    -

    xpath1.c: Evaluate XPath expression and prints result node set.

    -

    Shows how to evaluate XPath expression and register known namespaces in XPath context.

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    xpath1 <xml-file> <xpath-expr> [<known-ns-list>]

    -

    Author: Aleksey Sanin

    -

    xpath2.c: Load a document, locate subelements with XPath, modify said elements and save the resulting document.

    -

    Shows how to make a full round-trip from a load/edit/save

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    xpath2 <xml-file> <xpath-expr> <new-value>

    -

    Author: Aleksey Sanin and Daniel Veillard

    -

    xmlReader Examples

    -

    reader1.c: Parse an XML file with an xmlReader

    -

    Demonstrate the use of xmlReaderForFile() to parse an XML file and dump the information about the nodes found in the process. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    reader1 <filename>

    -

    Author: Daniel Veillard

    -

    reader2.c: Parse and validate an XML file with an xmlReader

    -

    Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    reader2 <valid_xml_filename>

    -

    Author: Daniel Veillard

    -

    reader3.c: Show how to extract subdocuments with xmlReader

    -

    Demonstrate the use of xmlTextReaderPreservePattern() to parse an XML file with the xmlReader while collecting only some subparts of the document. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    reader3

    -

    Author: Daniel Veillard

    -

    reader4.c: Parse multiple XML files reusing an xmlReader

    -

    Demonstrate the use of xmlReaderForFile() and xmlReaderNewFile to parse XML files while reusing the reader object and parser context. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    reader4 <filename> [ filename ... ]

    -

    Author: Graham Bennett

    -

    xmlWriter Examples

    -

    testWriter.c: use various APIs for the xmlWriter

    -

    tests a number of APIs for the xmlWriter, especially the various methods to write to a filename, to a memory buffer, to a new document, or to a subtree. It shows how to do encoding string conversions too. The resulting documents are then serialized.

    -

    Includes:

    - -

    Uses:

    - -

    Usage:

    -

    testWriter

    -

    Author: Alfred Mickautsch

    - - diff --git a/doc/examples/index.py b/doc/examples/index.py deleted file mode 100755 index bceae8b99..000000000 --- a/doc/examples/index.py +++ /dev/null @@ -1,290 +0,0 @@ -#!/usr/bin/env python3 -# -# Indexes the examples and build an XML description -# -import glob -import sys -try: - import libxml2 -except: - print("libxml2 python bindings not available") - sys.exit(1) -sys.path.insert(0, "..") -from apibuild import CParser, escape - -examples = [] -extras = ['examples.xsl', 'index.html', 'index.py'] -tests = [] -sections = {} -symbols = {} -api_dict = None -api_doc = None - -def load_api(): - global api_dict - global api_doc - - if api_dict != None: - return - api_dict = {} - try: - print("loading ../libxml2-api.xml") - api_doc = libxml2.parseFile("../libxml2-api.xml") - except: - print("failed to parse ../libxml2-api.xml") - sys.exit(1) - -def find_symbol(name): - global api_dict - global api_doc - - if api_doc == None: - load_api() - - if name == None: - return - if name in api_dict: - return api_dict[name] - ctxt = api_doc.xpathNewContext() - res = ctxt.xpathEval("/api/symbols/*[@name = '%s']" % (name)) - if type(res) == type([]) and len(res) >= 1: - if len(res) > 1: - print("Found %d references to %s in the API" % (len(res), name)) - node = res[0] - typ = node.name - file = node.xpathEval("string(@file)") - info = node.xpathEval("string(info)") - else: - print("Reference %s not found in the API" % (name)) - return None - ret = (typ, file, info) - api_dict[name] = ret - return ret - -def parse_top_comment(filename, comment): - res = {} - lines = comment.split("\n") - item = None - for line in lines: - while line != "" and (line[0] == ' ' or line[0] == '\t'): - line = line[1:] - while line != "" and line[0] == '*': - line = line[1:] - while line != "" and (line[0] == ' ' or line[0] == '\t'): - line = line[1:] - try: - (it, line) = line.split(":", 1) - item = it - while line != "" and (line[0] == ' ' or line[0] == '\t'): - line = line[1:] - if item in res: - res[item] = res[item] + " " + line - else: - res[item] = line - except: - if item != None: - if item in res: - res[item] = res[item] + " " + line - else: - res[item] = line - return res - -def parse(filename, output): - global symbols - global sections - - parser = CParser(filename) - parser.collect_references() - idx = parser.parse() - info = parse_top_comment(filename, parser.top_comment) - output.write(" \n" % filename) - try: - synopsis = info['synopsis'] - output.write(" %s\n" % escape(synopsis)); - except: - print("Example %s lacks a synopsis description" % (filename)) - try: - purpose = info['purpose'] - output.write(" %s\n" % escape(purpose)); - except: - print("Example %s lacks a purpose description" % (filename)) - try: - usage = info['usage'] - output.write(" %s\n" % escape(usage)); - except: - print("Example %s lacks an usage description" % (filename)) - try: - test = info['test'] - output.write(" %s\n" % escape(test)); - progname=filename[0:-2] - command=test.replace(progname, './' + progname, 1) - tests.append(command) - except: - pass - try: - author = info['author'] - output.write(" %s\n" % escape(author)); - except: - print("Example %s lacks an author description" % (filename)) - try: - copy = info['copy'] - output.write(" %s\n" % escape(copy)); - except: - print("Example %s lacks a copyright description" % (filename)) - try: - section = info['section'] - output.write("
    %s
    \n" % escape(section)); - if section in sections: - sections[section].append(filename) - else: - sections[section] = [filename] - except: - print("Example %s lacks a section description" % (filename)) - for topic in sorted(info.keys()): - if topic != "purpose" and topic != "usage" and \ - topic != "author" and topic != "copy" and \ - topic != "section" and topic != "synopsis" and topic != "test": - str = info[topic] - output.write(" %s\n" % ( - escape(topic), escape(str))) - output.write(" \n") - for include in sorted(idx.includes.keys()): - if include.find("libxml") != -1: - id = idx.includes[include] - line = id.get_lineno() - output.write(" %s\n" % - (line, escape(include))) - output.write(" \n") - output.write(" \n") - for ref in sorted(idx.references.keys()): - id = idx.references[ref] - name = id.get_name() - line = id.get_lineno() - if name in symbols: - sinfo = symbols[name] - refs = sinfo[0] - # gather at most 5 references per symbols - if refs > 5: - continue - sinfo.append(filename) - sinfo[0] = refs + 1 - else: - symbols[name] = [1, filename] - info = find_symbol(name) - if info != None: - type = info[0] - file = info[1] - output.write(" <%s line='%d' file='%s' name='%s'/>\n" % (type, - line, file, name)) - else: - type = id.get_type() - output.write(" <%s line='%d' name='%s'/>\n" % (type, - line, name)) - - output.write(" \n") - output.write("
    \n") - - return idx - -def dump_symbols(output): - global symbols - - output.write(" \n") - for symbol in sorted(symbols.keys()): - output.write(" \n" % (symbol)) - info = symbols[symbol] - i = 1 - while i < len(info): - output.write(" \n" % (info[i])) - i = i + 1 - output.write(" \n") - output.write(" \n") - -def dump_sections(output): - global sections - - output.write(" \n") - for section in sorted(sections.keys()): - output.write("
    \n" % (section)) - info = sections[section] - i = 0 - while i < len(info): - output.write(" \n" % (info[i])) - i = i + 1 - output.write("
    \n") - output.write("
    \n") - -def dump_Makefile(): - for file in glob.glob('*.xml'): - extras.append(file) - for file in glob.glob('*.res'): - extras.append(file) - Makefile="""## -## This file is auto-generated by index.py -## DO NOT EDIT !!! -## - -AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -LDADD = $(top_builddir)/libxml2.la - -CLEANFILES = *.tmp - -rebuild: -\tcd $(srcdir) && $(PYTHON) index.py -\t$(MAKE) Makefile -\tcd $(srcdir) && xsltproc examples.xsl examples.xml -\t-cd $(srcdir) && xmllint --valid --noout index.html - -.PHONY: rebuild - -install-data-local: -\t$(MKDIR_P) $(DESTDIR)$(docdir)/examples -\t-$(INSTALL) -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(DESTDIR)$(docdir)/examples/ - -clean-local: -\ttest -f Makefile.am || rm -f test?.xml - -""" - examples.sort() - extras.sort() - tests.sort() - EXTRA_DIST="" - for extra in extras: - EXTRA_DIST = EXTRA_DIST + " \\\n\t" + extra - Makefile = Makefile + "EXTRA_DIST =%s\n\n" % (EXTRA_DIST) - check_PROGRAMS="" - for example in examples: - check_PROGRAMS = check_PROGRAMS + " \\\n\t" + example - Makefile = Makefile + "check_PROGRAMS =%s\n\n" % (check_PROGRAMS) - for example in examples: - Makefile = Makefile + "%s_SOURCES = %s.c\n\n" % (example, example) - Makefile = Makefile + "valgrind: \n\t$(MAKE) CHECKER='valgrind' tests\n\n" - Makefile = Makefile + "tests: $(check_PROGRAMS)\n" - Makefile = Makefile + "\t@test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .\n" - Makefile = Makefile + "\t@(echo '## examples regression tests')\n" - for test in tests: - Makefile = Makefile + "\t@$(CHECKER) %s\n" % (test) - Makefile = Makefile + "\t@rm *.tmp\n" - try: - old = open("Makefile.am", "r").read() - if old != Makefile: - n = open("Makefile.am", "w").write(Makefile) - print("Updated Makefile.am") - except: - print("Failed to read or save Makefile.am") - -if __name__ == "__main__": - load_api() - output = open("examples.xml", "w") - output.write("\n") - - for file in sorted(glob.glob('*.c')): - parse(file, output) - examples.append(file[:-2]) - - dump_symbols(output) - dump_sections(output) - output.write("\n") - output.close() - #dump_Makefile() - diff --git a/doc/examples/meson.build b/doc/examples/meson.build deleted file mode 100644 index 3ce8f520e..000000000 --- a/doc/examples/meson.build +++ /dev/null @@ -1,59 +0,0 @@ - -## tests - -example_checks = [ - ['io1', ''], - ['io2', ''], - ['parse1', 'test1.xml'], - ['parse2', 'test2.xml'], - ['parse3', ''], - ['parse4', 'test3.xml'], - ['reader1', 'test2.xml'], - ['reader2', 'test2.xml'], - ['reader3', ''], - ['reader4', ['test1.xml', 'test2.xml', 'test3.xml']], - ['testWriter', ''], - ['tree1', 'test2.xml'], - ['tree2', ''], - ['xpath1', ['test3.xml', '//child2']], - ['xpath2', ['test3.xml', '//discarded', 'discarded']], -] - -foreach check : example_checks - exe = executable( - check[0], - files(check[0] + '.c'), - dependencies: xml_dep, - include_directories: config_dir, - ) - test( - check[0], - exe, - args: check[1], - timeout: 0, - workdir: meson.current_source_dir(), - ) -endforeach - -## example files - -example_files = files( - 'index.html', - 'io1.c', - 'io2.c', - 'parse1.c', - 'parse2.c', - 'parse3.c', - 'parse4.c', - 'reader1.c', - 'reader2.c', - 'reader3.c', - 'reader4.c', - 'testWriter.c', - 'tree1.c', - 'tree2.c', - 'xpath1.c', - 'xpath2.c', -) - -install_data(example_files, install_dir: dir_doc / 'examples') diff --git a/doc/meson.build b/doc/meson.build index 8a2c3462d..cf8e87938 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -10,5 +10,4 @@ tutorial_files = files( install_data(tutorial_files, install_dir: dir_doc) subdir('devhelp') -subdir('examples') subdir('tutorial') diff --git a/doc/examples/.gitignore b/example/.gitignore similarity index 92% rename from doc/examples/.gitignore rename to example/.gitignore index ec244f234..04c5cb3b2 100644 --- a/doc/examples/.gitignore +++ b/example/.gitignore @@ -1,3 +1,4 @@ +/gjobread /io1 /io2 /parse1 diff --git a/example/Makefile.am b/example/Makefile.am index 0f6fb58b2..791764fac 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -1,8 +1,44 @@ -check_PROGRAMS = gjobread +EXTRA_DIST = \ + gjobs.xml \ + meson.build \ + test1.xml \ + test2.xml \ + test3.xml + +check_PROGRAMS = \ + gjobread \ + io1 \ + io2 \ + parse1 \ + parse2 \ + parse3 \ + parse4 \ + reader1 \ + reader2 \ + reader3 \ + reader4 \ + testWriter \ + tree1 \ + tree2 \ + xpath1 \ + xpath2 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include LDADD = $(top_builddir)/libxml2.la gjobread_SOURCES=gjobread.c - -EXTRA_DIST = meson.build +io1_SOURCES = io1.c +io2_SOURCES = io2.c +parse1_SOURCES = parse1.c +parse2_SOURCES = parse2.c +parse3_SOURCES = parse3.c +parse4_SOURCES = parse4.c +reader1_SOURCES = reader1.c +reader2_SOURCES = reader2.c +reader3_SOURCES = reader3.c +reader4_SOURCES = reader4.c +testWriter_SOURCES = testWriter.c +tree1_SOURCES = tree1.c +tree2_SOURCES = tree2.c +xpath1_SOURCES = xpath1.c +xpath2_SOURCES = xpath2.c diff --git a/doc/examples/io1.c b/example/io1.c similarity index 100% rename from doc/examples/io1.c rename to example/io1.c diff --git a/doc/examples/io2.c b/example/io2.c similarity index 100% rename from doc/examples/io2.c rename to example/io2.c diff --git a/example/meson.build b/example/meson.build index d95e5afff..b6515ab46 100644 --- a/example/meson.build +++ b/example/meson.build @@ -1,8 +1,27 @@ - -exe = executable( +examples = [ 'gjobread', - files('gjobread.c'), - dependencies: xml_dep, - include_directories: config_dir, -) -test('gjobread', exe, timeout: 0) + 'io1', + 'io2', + 'parse1', + 'parse2', + 'parse3', + 'parse4', + 'reader1', + 'reader2', + 'reader3', + 'reader4', + 'testWriter', + 'tree1', + 'tree2', + 'xpath1', + 'xpath2', +] + +foreach example : examples + exe = executable( + example, + files(example + '.c'), + dependencies: xml_dep, + include_directories: config_dir, + ) +endforeach diff --git a/doc/examples/parse1.c b/example/parse1.c similarity index 100% rename from doc/examples/parse1.c rename to example/parse1.c diff --git a/doc/examples/parse2.c b/example/parse2.c similarity index 100% rename from doc/examples/parse2.c rename to example/parse2.c diff --git a/doc/examples/parse3.c b/example/parse3.c similarity index 100% rename from doc/examples/parse3.c rename to example/parse3.c diff --git a/doc/examples/parse4.c b/example/parse4.c similarity index 100% rename from doc/examples/parse4.c rename to example/parse4.c diff --git a/doc/examples/reader1.c b/example/reader1.c similarity index 100% rename from doc/examples/reader1.c rename to example/reader1.c diff --git a/doc/examples/reader2.c b/example/reader2.c similarity index 100% rename from doc/examples/reader2.c rename to example/reader2.c diff --git a/doc/examples/reader3.c b/example/reader3.c similarity index 100% rename from doc/examples/reader3.c rename to example/reader3.c diff --git a/doc/examples/reader4.c b/example/reader4.c similarity index 100% rename from doc/examples/reader4.c rename to example/reader4.c diff --git a/doc/examples/test1.xml b/example/test1.xml similarity index 100% rename from doc/examples/test1.xml rename to example/test1.xml diff --git a/doc/examples/test2.xml b/example/test2.xml similarity index 100% rename from doc/examples/test2.xml rename to example/test2.xml diff --git a/doc/examples/test3.xml b/example/test3.xml similarity index 100% rename from doc/examples/test3.xml rename to example/test3.xml diff --git a/doc/examples/testWriter.c b/example/testWriter.c similarity index 100% rename from doc/examples/testWriter.c rename to example/testWriter.c diff --git a/doc/examples/tree1.c b/example/tree1.c similarity index 100% rename from doc/examples/tree1.c rename to example/tree1.c diff --git a/doc/examples/tree2.c b/example/tree2.c similarity index 100% rename from doc/examples/tree2.c rename to example/tree2.c diff --git a/doc/examples/xpath1.c b/example/xpath1.c similarity index 100% rename from doc/examples/xpath1.c rename to example/xpath1.c diff --git a/doc/examples/xpath2.c b/example/xpath2.c similarity index 100% rename from doc/examples/xpath2.c rename to example/xpath2.c From 5f75c9560f0a510b2d8b1c322b199c7b9453672c Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 28 Apr 2024 22:57:02 +0200 Subject: [PATCH 417/504] doc: Remove tutorial The tutorial was moved to the Wiki: https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Tutorial --- .gitlab-ci.yml | 2 +- doc/Makefile.am | 49 -- doc/meson.build | 1 - doc/tutorial/apa.html | 8 - doc/tutorial/apb.html | 14 - doc/tutorial/apc.html | 82 --- doc/tutorial/apd.html | 76 --- doc/tutorial/ape.html | 78 --- doc/tutorial/apf.html | 67 --- doc/tutorial/apg.html | 75 --- doc/tutorial/aph.html | 76 --- doc/tutorial/api.html | 4 - doc/tutorial/ar01s02.html | 14 - doc/tutorial/ar01s03.html | 47 -- doc/tutorial/ar01s04.html | 54 -- doc/tutorial/ar01s05.html | 55 -- doc/tutorial/ar01s06.html | 35 -- doc/tutorial/ar01s07.html | 30 -- doc/tutorial/ar01s08.html | 38 -- doc/tutorial/ar01s09.html | 63 --- doc/tutorial/customfo.xsl | 22 - doc/tutorial/customhtml.xsl | 18 - doc/tutorial/images/blank.png | Bin 374 -> 0 bytes doc/tutorial/images/callouts/1.png | Bin 329 -> 0 bytes doc/tutorial/images/callouts/10.png | Bin 361 -> 0 bytes doc/tutorial/images/callouts/2.png | Bin 353 -> 0 bytes doc/tutorial/images/callouts/3.png | Bin 350 -> 0 bytes doc/tutorial/images/callouts/4.png | Bin 345 -> 0 bytes doc/tutorial/images/callouts/5.png | Bin 348 -> 0 bytes doc/tutorial/images/callouts/6.png | Bin 355 -> 0 bytes doc/tutorial/images/callouts/7.png | Bin 344 -> 0 bytes doc/tutorial/images/callouts/8.png | Bin 357 -> 0 bytes doc/tutorial/images/callouts/9.png | Bin 357 -> 0 bytes doc/tutorial/images/caution.png | Bin 1250 -> 0 bytes doc/tutorial/images/draft.png | Bin 17454 -> 0 bytes doc/tutorial/images/home.png | Bin 1156 -> 0 bytes doc/tutorial/images/important.png | Bin 722 -> 0 bytes doc/tutorial/images/next.png | Bin 1150 -> 0 bytes doc/tutorial/images/note.png | Bin 490 -> 0 bytes doc/tutorial/images/prev.png | Bin 1132 -> 0 bytes doc/tutorial/images/tip.png | Bin 449 -> 0 bytes doc/tutorial/images/toc-blank.png | Bin 318 -> 0 bytes doc/tutorial/images/toc-minus.png | Bin 259 -> 0 bytes doc/tutorial/images/toc-plus.png | Bin 264 -> 0 bytes doc/tutorial/images/up.png | Bin 1111 -> 0 bytes doc/tutorial/images/warning.png | Bin 1241 -> 0 bytes doc/tutorial/includeaddattribute.c | 64 --- doc/tutorial/includeaddkeyword.c | 75 --- doc/tutorial/includeconvert.c | 73 --- doc/tutorial/includegetattribute.c | 72 --- doc/tutorial/includekeyword.c | 79 --- doc/tutorial/includestory.xml | 14 - doc/tutorial/includexpath.c | 74 --- doc/tutorial/index.html | 14 - doc/tutorial/ix01.html | 1 - doc/tutorial/meson.build | 82 --- doc/tutorial/xmltutorial.xml | 747 ---------------------------- 57 files changed, 1 insertion(+), 2202 deletions(-) delete mode 100644 doc/tutorial/apa.html delete mode 100644 doc/tutorial/apb.html delete mode 100644 doc/tutorial/apc.html delete mode 100644 doc/tutorial/apd.html delete mode 100644 doc/tutorial/ape.html delete mode 100644 doc/tutorial/apf.html delete mode 100644 doc/tutorial/apg.html delete mode 100644 doc/tutorial/aph.html delete mode 100644 doc/tutorial/api.html delete mode 100644 doc/tutorial/ar01s02.html delete mode 100644 doc/tutorial/ar01s03.html delete mode 100644 doc/tutorial/ar01s04.html delete mode 100644 doc/tutorial/ar01s05.html delete mode 100644 doc/tutorial/ar01s06.html delete mode 100644 doc/tutorial/ar01s07.html delete mode 100644 doc/tutorial/ar01s08.html delete mode 100644 doc/tutorial/ar01s09.html delete mode 100644 doc/tutorial/customfo.xsl delete mode 100644 doc/tutorial/customhtml.xsl delete mode 100644 doc/tutorial/images/blank.png delete mode 100644 doc/tutorial/images/callouts/1.png delete mode 100644 doc/tutorial/images/callouts/10.png delete mode 100644 doc/tutorial/images/callouts/2.png delete mode 100644 doc/tutorial/images/callouts/3.png delete mode 100644 doc/tutorial/images/callouts/4.png delete mode 100644 doc/tutorial/images/callouts/5.png delete mode 100644 doc/tutorial/images/callouts/6.png delete mode 100644 doc/tutorial/images/callouts/7.png delete mode 100644 doc/tutorial/images/callouts/8.png delete mode 100644 doc/tutorial/images/callouts/9.png delete mode 100644 doc/tutorial/images/caution.png delete mode 100644 doc/tutorial/images/draft.png delete mode 100644 doc/tutorial/images/home.png delete mode 100644 doc/tutorial/images/important.png delete mode 100644 doc/tutorial/images/next.png delete mode 100644 doc/tutorial/images/note.png delete mode 100644 doc/tutorial/images/prev.png delete mode 100644 doc/tutorial/images/tip.png delete mode 100644 doc/tutorial/images/toc-blank.png delete mode 100644 doc/tutorial/images/toc-minus.png delete mode 100644 doc/tutorial/images/toc-plus.png delete mode 100644 doc/tutorial/images/up.png delete mode 100644 doc/tutorial/images/warning.png delete mode 100644 doc/tutorial/includeaddattribute.c delete mode 100644 doc/tutorial/includeaddkeyword.c delete mode 100644 doc/tutorial/includeconvert.c delete mode 100644 doc/tutorial/includegetattribute.c delete mode 100644 doc/tutorial/includekeyword.c delete mode 100644 doc/tutorial/includestory.xml delete mode 100644 doc/tutorial/includexpath.c delete mode 100644 doc/tutorial/index.html delete mode 100644 doc/tutorial/ix01.html delete mode 100644 doc/tutorial/meson.build delete mode 100644 doc/tutorial/xmltutorial.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4e8c0eaf..614808254 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -289,7 +289,7 @@ cmake:linux:gcc:shared: pages: script: - mkdir -p public - - cp -r doc/devhelp doc/tutorial doc/xmllint.html doc/xmlcatalog.html public + - cp -r doc/devhelp doc/xmllint.html doc/xmlcatalog.html public artifacts: paths: - public diff --git a/doc/Makefile.am b/doc/Makefile.am index 577bb34ab..aebad07ae 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -2,55 +2,6 @@ SUBDIRS = . devhelp nobase_dist_doc_DATA = \ - tutorial/apa.html \ - tutorial/apb.html \ - tutorial/apc.html \ - tutorial/apd.html \ - tutorial/ape.html \ - tutorial/apf.html \ - tutorial/apg.html \ - tutorial/aph.html \ - tutorial/api.html \ - tutorial/ar01s02.html \ - tutorial/ar01s03.html \ - tutorial/ar01s04.html \ - tutorial/ar01s05.html \ - tutorial/ar01s06.html \ - tutorial/ar01s07.html \ - tutorial/ar01s08.html \ - tutorial/ar01s09.html \ - tutorial/images/blank.png \ - tutorial/images/callouts/1.png \ - tutorial/images/callouts/10.png \ - tutorial/images/callouts/2.png \ - tutorial/images/callouts/3.png \ - tutorial/images/callouts/4.png \ - tutorial/images/callouts/5.png \ - tutorial/images/callouts/6.png \ - tutorial/images/callouts/7.png \ - tutorial/images/callouts/8.png \ - tutorial/images/callouts/9.png \ - tutorial/images/caution.png \ - tutorial/images/draft.png \ - tutorial/images/home.png \ - tutorial/images/important.png \ - tutorial/images/next.png \ - tutorial/images/note.png \ - tutorial/images/prev.png \ - tutorial/images/tip.png \ - tutorial/images/toc-blank.png \ - tutorial/images/toc-minus.png \ - tutorial/images/toc-plus.png \ - tutorial/images/up.png \ - tutorial/images/warning.png \ - tutorial/includeaddattribute.c \ - tutorial/includeaddkeyword.c \ - tutorial/includeconvert.c \ - tutorial/includegetattribute.c \ - tutorial/includekeyword.c \ - tutorial/includexpath.c \ - tutorial/index.html \ - tutorial/ix01.html \ xmlcatalog.html \ xmllint.html diff --git a/doc/meson.build b/doc/meson.build index cf8e87938..1ae3eccd3 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -10,4 +10,3 @@ tutorial_files = files( install_data(tutorial_files, install_dir: dir_doc) subdir('devhelp') -subdir('tutorial') diff --git a/doc/tutorial/apa.html b/doc/tutorial/apa.html deleted file mode 100644 index 964e15f4e..000000000 --- a/doc/tutorial/apa.html +++ /dev/null @@ -1,8 +0,0 @@ -A.Compilation

    A.Compilation

    - Libxml includes a script, - xml2-config, that can be used to generate - flags for compilation and linking of programs written with the - library. For pre-processor and compiler flags, use xml2-config - --cflags. For library linking flags, use xml2-config - --libs. Other options are available using xml2-config - --help.

    diff --git a/doc/tutorial/apb.html b/doc/tutorial/apb.html deleted file mode 100644 index ef14066b8..000000000 --- a/doc/tutorial/apb.html +++ /dev/null @@ -1,14 +0,0 @@ -B.Sample Document

    B.Sample Document

    -<?xml version="1.0"?>
    -<story>
    -  <storyinfo>
    -    <author>John Fleck</author>
    -    <datewritten>June 2, 2002</datewritten>
    -    <keyword>example keyword</keyword>
    -  </storyinfo>
    -  <body>
    -    <headline>This is the headline</headline>
    -    <para>This is the body text.</para>
    -  </body>
    -</story>
    -
    diff --git a/doc/tutorial/apc.html b/doc/tutorial/apc.html deleted file mode 100644 index f8d991117..000000000 --- a/doc/tutorial/apc.html +++ /dev/null @@ -1,82 +0,0 @@ -C.Code for Keyword Example

    C.Code for Keyword Example

    -

    -#include <stdio.h>
    -#include <string.h>
    -#include <stdlib.h>
    -#include <libxml/xmlmemory.h>
    -#include <libxml/parser.h>
    -
    -void
    -parseStory (xmlDocPtr doc, xmlNodePtr cur) {
    -
    -	xmlChar *key;
    -	cur = cur->xmlChildrenNode;
    -	while (cur != NULL) {
    -	    if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) {
    -		    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
    -		    printf("keyword: %s\n", key);
    -		    xmlFree(key);
    - 	    }
    -	cur = cur->next;
    -	}
    -    return;
    -}
    -
    -static void
    -parseDoc(char *docname) {
    -
    -	xmlDocPtr doc;
    -	xmlNodePtr cur;
    -
    -	doc = xmlParseFile(docname);
    -	
    -	if (doc == NULL ) {
    -		fprintf(stderr,"Document not parsed successfully. \n");
    -		return;
    -	}
    -	
    -	cur = xmlDocGetRootElement(doc);
    -	
    -	if (cur == NULL) {
    -		fprintf(stderr,"empty document\n");
    -		xmlFreeDoc(doc);
    -		return;
    -	}
    -	
    -	if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
    -		fprintf(stderr,"document of the wrong type, root node != story");
    -		xmlFreeDoc(doc);
    -		return;
    -	}
    -	
    -	cur = cur->xmlChildrenNode;
    -	while (cur != NULL) {
    -		if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){
    -			parseStory (doc, cur);
    -		}
    -		 
    -	cur = cur->next;
    -	}
    -	
    -	xmlFreeDoc(doc);
    -	return;
    -}
    -
    -int
    -main(int argc, char **argv) {
    -
    -	char *docname;
    -		
    -	if (argc <= 1) {
    -		printf("Usage: %s docname\n", argv[0]);
    -		return(0);
    -	}
    -
    -	docname = argv[1];
    -	parseDoc (docname);
    -
    -	return (1);
    -}
    -
    -

    -

    diff --git a/doc/tutorial/apd.html b/doc/tutorial/apd.html deleted file mode 100644 index 8f9618d52..000000000 --- a/doc/tutorial/apd.html +++ /dev/null @@ -1,76 +0,0 @@ -D.Code for XPath Example

    D.Code for XPath Example

    -

    -#include <libxml/parser.h>
    -#include <libxml/xpath.h>
    -
    -xmlDocPtr
    -getdoc (char *docname) {
    -	xmlDocPtr doc;
    -	doc = xmlParseFile(docname);
    -	
    -	if (doc == NULL ) {
    -		fprintf(stderr,"Document not parsed successfully. \n");
    -		return NULL;
    -	}
    -
    -	return doc;
    -}
    -
    -xmlXPathObjectPtr
    -getnodeset (xmlDocPtr doc, xmlChar *xpath){
    -	
    -	xmlXPathContextPtr context;
    -	xmlXPathObjectPtr result;
    -
    -	context = xmlXPathNewContext(doc);
    -	if (context == NULL) {
    -		printf("Error in xmlXPathNewContext\n");
    -		return NULL;
    -	}
    -	result = xmlXPathEvalExpression(xpath, context);
    -	xmlXPathFreeContext(context);
    -	if (result == NULL) {
    -		printf("Error in xmlXPathEvalExpression\n");
    -		return NULL;
    -	}
    -	if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
    -		xmlXPathFreeObject(result);
    -                printf("No result\n");
    -		return NULL;
    -	}
    -	return result;
    -}
    -int
    -main(int argc, char **argv) {
    -
    -	char *docname;
    -	xmlDocPtr doc;
    -	xmlChar *xpath = (xmlChar*) "//keyword";
    -	xmlNodeSetPtr nodeset;
    -	xmlXPathObjectPtr result;
    -	int i;
    -	xmlChar *keyword;
    -		
    -	if (argc <= 1) {
    -		printf("Usage: %s docname\n", argv[0]);
    -		return(0);
    -	}
    -
    -	docname = argv[1];
    -	doc = getdoc(docname);
    -	result = getnodeset (doc, xpath);
    -	if (result) {
    -		nodeset = result->nodesetval;
    -		for (i=0; i < nodeset->nodeNr; i++) {
    -			keyword = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1);
    -		printf("keyword: %s\n", keyword);
    -		xmlFree(keyword);
    -		}
    -		xmlXPathFreeObject (result);
    -	}
    -	xmlFreeDoc(doc);
    -	xmlCleanupParser();
    -	return (1);
    -}
    -

    -

    diff --git a/doc/tutorial/ape.html b/doc/tutorial/ape.html deleted file mode 100644 index 200319a07..000000000 --- a/doc/tutorial/ape.html +++ /dev/null @@ -1,78 +0,0 @@ -E.Code for Add Keyword Example

    E.Code for Add Keyword Example

    -

    -#include <stdio.h>
    -#include <string.h>
    -#include <stdlib.h>
    -#include <libxml/xmlmemory.h>
    -#include <libxml/parser.h>
    -
    -void
    -parseStory (xmlDocPtr doc, xmlNodePtr cur, char *keyword) {
    -
    -	xmlNewTextChild (cur, NULL, "keyword", keyword);
    -    return;
    -}
    -
    -xmlDocPtr
    -parseDoc(char *docname, char *keyword) {
    -
    -	xmlDocPtr doc;
    -	xmlNodePtr cur;
    -
    -	doc = xmlParseFile(docname);
    -	
    -	if (doc == NULL ) {
    -		fprintf(stderr,"Document not parsed successfully. \n");
    -		return (NULL);
    -	}
    -	
    -	cur = xmlDocGetRootElement(doc);
    -	
    -	if (cur == NULL) {
    -		fprintf(stderr,"empty document\n");
    -		xmlFreeDoc(doc);
    -		return (NULL);
    -	}
    -	
    -	if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
    -		fprintf(stderr,"document of the wrong type, root node != story");
    -		xmlFreeDoc(doc);
    -		return (NULL);
    -	}
    -	
    -	cur = cur->xmlChildrenNode;
    -	while (cur != NULL) {
    -		if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){
    -			parseStory (doc, cur, keyword);
    -		}
    -		 
    -	cur = cur->next;
    -	}
    -	return(doc);
    -}
    -
    -int
    -main(int argc, char **argv) {
    -
    -	char *docname;
    -	char *keyword;
    -	xmlDocPtr doc;
    -
    -	if (argc <= 2) {
    -		printf("Usage: %s docname, keyword\n", argv[0]);
    -		return(0);
    -	}
    -
    -	docname = argv[1];
    -	keyword = argv[2];
    -	doc = parseDoc (docname, keyword);
    -	if (doc != NULL) {
    -		xmlSaveFormatFile (docname, doc, 0);
    -		xmlFreeDoc(doc);
    -	}
    -	
    -	return (1);
    -}
    -
    -

    -

    diff --git a/doc/tutorial/apf.html b/doc/tutorial/apf.html deleted file mode 100644 index 4848cdbfe..000000000 --- a/doc/tutorial/apf.html +++ /dev/null @@ -1,67 +0,0 @@ -F.Code for Add Attribute Example

    F.Code for Add Attribute Example

    -

    -#include <stdio.h>
    -#include <string.h>
    -#include <stdlib.h>
    -#include <libxml/xmlmemory.h>
    -#include <libxml/parser.h>
    -
    -
    -xmlDocPtr
    -parseDoc(char *docname, char *uri) {
    -
    -	xmlDocPtr doc;
    -	xmlNodePtr cur;
    -	xmlNodePtr newnode;
    -	xmlAttrPtr newattr;
    -
    -	doc = xmlParseFile(docname);
    -	
    -	if (doc == NULL ) {
    -		fprintf(stderr,"Document not parsed successfully. \n");
    -		return (NULL);
    -	}
    -	
    -	cur = xmlDocGetRootElement(doc);
    -	
    -	if (cur == NULL) {
    -		fprintf(stderr,"empty document\n");
    -		xmlFreeDoc(doc);
    -		return (NULL);
    -	}
    -	
    -	if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
    -		fprintf(stderr,"document of the wrong type, root node != story");
    -		xmlFreeDoc(doc);
    -		return (NULL);
    -	}
    -	
    -	newnode = xmlNewTextChild (cur, NULL, "reference", NULL);
    -	newattr = xmlNewProp (newnode, "uri", uri);
    -	return(doc);
    -}
    -
    -int
    -main(int argc, char **argv) {
    -
    -	char *docname;
    -	char *uri;
    -	xmlDocPtr doc;
    -
    -	if (argc <= 2) {
    -		printf("Usage: %s docname, uri\n", argv[0]);
    -		return(0);
    -	}
    -
    -	docname = argv[1];
    -	uri = argv[2];
    -	doc = parseDoc (docname, uri);
    -	if (doc != NULL) {
    -		xmlSaveFormatFile (docname, doc, 1);
    -		xmlFreeDoc(doc);
    -	}
    -	return (1);
    -}
    -
    -

    -

    diff --git a/doc/tutorial/apg.html b/doc/tutorial/apg.html deleted file mode 100644 index fffa0eed6..000000000 --- a/doc/tutorial/apg.html +++ /dev/null @@ -1,75 +0,0 @@ -G.Code for Retrieving Attribute Value Example

    G.Code for Retrieving Attribute Value Example

    -

    -#include <stdio.h>
    -#include <string.h>
    -#include <stdlib.h>
    -#include <libxml/xmlmemory.h>
    -#include <libxml/parser.h>
    -
    -void
    -getReference (xmlDocPtr doc, xmlNodePtr cur) {
    -
    -	xmlChar *uri;
    -	cur = cur->xmlChildrenNode;
    -	while (cur != NULL) {
    -	    if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) {
    -		    uri = xmlGetProp(cur, "uri");
    -		    printf("uri: %s\n", uri);
    -		    xmlFree(uri);
    -	    }
    -	    cur = cur->next;
    -	}
    -	return;
    -}
    -
    -
    -void
    -parseDoc(char *docname) {
    -
    -	xmlDocPtr doc;
    -	xmlNodePtr cur;
    -
    -	doc = xmlParseFile(docname);
    -	
    -	if (doc == NULL ) {
    -		fprintf(stderr,"Document not parsed successfully. \n");
    -		return;
    -	}
    -	
    -	cur = xmlDocGetRootElement(doc);
    -	
    -	if (cur == NULL) {
    -		fprintf(stderr,"empty document\n");
    -		xmlFreeDoc(doc);
    -		return;
    -	}
    -	
    -	if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
    -		fprintf(stderr,"document of the wrong type, root node != story");
    -		xmlFreeDoc(doc);
    -		return;
    -	}
    -	
    -	getReference (doc, cur);
    -	xmlFreeDoc(doc);
    -	return;
    -}
    -
    -int
    -main(int argc, char **argv) {
    -
    -	char *docname;
    -
    -	if (argc <= 1) {
    -		printf("Usage: %s docname\n", argv[0]);
    -		return(0);
    -	}
    -
    -	docname = argv[1];
    -	parseDoc (docname);
    -	
    -	return (1);
    -}
    -
    -

    -

    diff --git a/doc/tutorial/aph.html b/doc/tutorial/aph.html deleted file mode 100644 index ef466057a..000000000 --- a/doc/tutorial/aph.html +++ /dev/null @@ -1,76 +0,0 @@ -H.Code for Encoding Conversion Example

    H.Code for Encoding Conversion Example

    -

    -#include <string.h>
    -#include <libxml/parser.h>
    -
    -
    -unsigned char*
    -convert (unsigned char *in, char *encoding)
    -{
    -	unsigned char *out;
    -        int ret,size,out_size,temp;
    -        xmlCharEncodingHandlerPtr handler;
    -
    -        size = (int)strlen(in)+1; 
    -        out_size = size*2-1; 
    -        out = malloc((size_t)out_size); 
    -
    -        if (out) {
    -                handler = xmlFindCharEncodingHandler(encoding);
    -                
    -                if (!handler) {
    -                        free(out);
    -                        out = NULL;
    -                }
    -        }
    -        if (out) {
    -                temp=size-1;
    -                ret = handler->input(out, &out_size, in, &temp);
    -                if (ret || temp-size+1) {
    -                        if (ret) {
    -                                printf("conversion wasn't successful.\n");
    -                        } else {
    -                                printf("conversion wasn't successful. converted: %i octets.\n",temp);
    -                        }
    -                        free(out);
    -                        out = NULL;
    -                } else {
    -                        out = realloc(out,out_size+1); 
    -                        out[out_size]=0; /*null terminating out*/
    -                        
    -                }
    -        } else {
    -                printf("no mem\n");
    -        }
    -        return (out);
    -}	
    -
    -
    -int
    -main(int argc, char **argv) {
    -
    -	unsigned char *content, *out;
    -	xmlDocPtr doc;
    -	xmlNodePtr rootnode;
    -	char *encoding = "ISO-8859-1";
    -	
    -		
    -	if (argc <= 1) {
    -		printf("Usage: %s content\n", argv[0]);
    -		return(0);
    -	}
    -
    -	content = argv[1];
    -
    -	out = convert(content, encoding);
    -
    -	doc = xmlNewDoc ("1.0");
    -	rootnode = xmlNewDocNode(doc, NULL, (const xmlChar*)"root", out);
    -	xmlDocSetRootElement(doc, rootnode);
    -
    -	xmlSaveFormatFileEnc("-", doc, encoding, 1);
    -	return (1);
    -}
    -
    -

    -

    diff --git a/doc/tutorial/api.html b/doc/tutorial/api.html deleted file mode 100644 index 16e798123..000000000 --- a/doc/tutorial/api.html +++ /dev/null @@ -1,4 +0,0 @@ -I.Acknowledgements

    I.Acknowledgements

    A number of people have generously offered feedback, code and - suggested improvements to this tutorial. In no particular order: - Daniel Veillard, Marcus Labib Iskander, Christopher R. Harris, Igor Zlatkovic, Niraj Tolia, David Turover -

    diff --git a/doc/tutorial/ar01s02.html b/doc/tutorial/ar01s02.html deleted file mode 100644 index 8aebcec3c..000000000 --- a/doc/tutorial/ar01s02.html +++ /dev/null @@ -1,14 +0,0 @@ -Data Types

    Data Types

    Libxml declares a number of data types we - will encounter repeatedly, hiding the messy stuff so you do not have to deal - with it unless you have some specific need.

    -

    -xmlChar

    A basic replacement for char, a byte in a UTF-8 encoded - string. If your data uses another encoding, it must be converted to - UTF-8 for use with libxml's - functions. More information on encoding is available on the libxml encoding support web page.

    - xmlDoc

    A structure containing the tree created by a parsed doc. xmlDocPtr - is a pointer to the structure.

    -xmlNodePtr - and xmlNode

    A structure containing a single node. xmlNodePtr - is a pointer to the structure, and is used in traversing the document tree.

    -

    diff --git a/doc/tutorial/ar01s03.html b/doc/tutorial/ar01s03.html deleted file mode 100644 index cd28fff54..000000000 --- a/doc/tutorial/ar01s03.html +++ /dev/null @@ -1,47 +0,0 @@ -Parsing the file

    Parsing the file

    -Parsing the file requires only the name of the file and a single - function call, plus error checking. Full code: AppendixC, Code for Keyword Example

    -

    -        1 xmlDocPtr doc;
    -	2 xmlNodePtr cur;
    -
    -	3 doc = xmlParseFile(docname);
    -	
    -	4 if (doc == NULL ) {
    -		fprintf(stderr,"Document not parsed successfully. \n");
    -		return;
    -	}
    -
    -	5 cur = xmlDocGetRootElement(doc);
    -	
    -	6 if (cur == NULL) {
    -		fprintf(stderr,"empty document\n");
    -		xmlFreeDoc(doc);
    -		return;
    -	}
    -	
    -	7 if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
    -		fprintf(stderr,"document of the wrong type, root node != story");
    -		xmlFreeDoc(doc);
    -		return;
    -	}
    -
    -    

    -

    1

    Declare the pointer that will point to your parsed document.

    2

    Declare a node pointer (you'll need this in order to - interact with individual nodes).

    4

    Check to see that the document was successfully parsed. If it - was not, libxml will at this point - register an error and stop. -

    [Note]Note

    -One common example of an error at this point is improper - handling of encoding. The XML standard requires - documents stored with an encoding other than UTF-8 or UTF-16 to - contain an explicit declaration of their encoding. If the - declaration is there, libxml will - automatically perform the necessary conversion to UTF-8 for - you. More information on XML's encoding - requirements is contained in the standard.

    -

    5

    Retrieve the document's root element.

    6

    Check to make sure the document actually contains something.

    7

    In our case, we need to make sure the document is the right - type. "story" is the root type of the documents used in this - tutorial.

    - -

    diff --git a/doc/tutorial/ar01s04.html b/doc/tutorial/ar01s04.html deleted file mode 100644 index 1acad38e0..000000000 --- a/doc/tutorial/ar01s04.html +++ /dev/null @@ -1,54 +0,0 @@ -Retrieving Element Content

    Retrieving Element Content

    -Retrieving the content of an element involves traversing the document - tree until you find what you are looking for. In this case, we are looking - for an element called "keyword" contained within element called "story". The - process to find the node we are interested in involves tediously walking the - tree. We assume you already have an xmlDocPtr called doc - and an xmlNodPtr called cur.

    -

    -	1cur = cur->xmlChildrenNode;
    -	2while (cur != NULL) {
    -		if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){
    -			parseStory (doc, cur);
    -		}
    -		 
    -	cur = cur->next;
    -	}
    -      

    - -

    1

    Get the first child node of cur. At this - point, cur points at the document root, which is - the element "story".

    2

    This loop iterates through the elements that are children of - "story", looking for one called "storyinfo". That - is the element that will contain the "keywords" we are - looking for. It uses the libxml string - comparison - function, xmlStrcmp. If there is a match, it calls the function parseStory.

    -

    -

    -void
    -parseStory (xmlDocPtr doc, xmlNodePtr cur) {
    -
    -	xmlChar *key;
    -	1 cur = cur->xmlChildrenNode;
    -	2 while (cur != NULL) {
    -	    if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) {
    -	3	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
    -		    printf("keyword: %s\n", key);
    -		    xmlFree(key);
    - 	    }
    -	cur = cur->next;
    -	}
    -    return;
    -}
    -      

    -

    1

    Again we get the first child node.

    2

    Like the loop above, we then iterate through the nodes, looking - for one that matches the element we're interested in, in this case - "keyword".

    3

    When we find the "keyword" element, we need to print - its contents. Remember that in XML, the text - contained within an element is a child node of that element, so we - turn to cur->xmlChildrenNode. To retrieve it, we - use the function xmlNodeListGetString, which also takes the doc pointer as an argument. In this case, we just print it out.

    [Note]Note

    Because xmlNodeListGetString allocates - memory for the string it returns, you must use - xmlFree to free it.

    -

    diff --git a/doc/tutorial/ar01s05.html b/doc/tutorial/ar01s05.html deleted file mode 100644 index 919d4544d..000000000 --- a/doc/tutorial/ar01s05.html +++ /dev/null @@ -1,55 +0,0 @@ -Using XPath to Retrieve Element Content

    Using XPath to Retrieve Element Content

    In addition to walking the document tree to find an element, - Libxml2 includes support for - use of XPath expressions to retrieve sets of - nodes that match a specified criteria. Full documentation of the - XPath API is here. -

    XPath allows searching through a document - for nodes that match specified criteria. In the example below we search - through a document for the contents of all keyword - elements. -

    [Note]Note

    A full discussion of XPath is beyond - the scope of this document. For details on its use, see the XPath specification.

    - Full code for this example is at AppendixD, Code for XPath Example. -

    Using XPath requires setting up an - xmlXPathContext and then supplying the XPath - expression and the context to the - xmlXPathEvalExpression function. The function returns - an xmlXPathObjectPtr, which includes the set of nodes satisfying the - XPath expression.

    -

    -	xmlXPathObjectPtr
    -	getnodeset (xmlDocPtr doc, xmlChar *xpath){
    -	
    -	1xmlXPathContextPtr context;
    -	xmlXPathObjectPtr result;
    -
    -	2context = xmlXPathNewContext(doc);
    -	3result = xmlXPathEvalExpression(xpath, context);
    -	4if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
    -		xmlXPathFreeObject(result);
    -                printf("No result\n");
    -		return NULL;
    -      

    -

    1

    First we declare our variables.

    2

    Initialize the context variable.

    3

    Apply the XPath expression.

    4

    Check the result and free the memory allocated to - result if no result is found.

    -

    The xmlPathObjectPtr returned by the function contains a set of nodes - and other information needed to iterate through the set and act on the - results. For this example, our functions returns the - xmlXPathObjectPtr. We use it to print the contents of - keyword nodes in our document. The node set object - includes the number of elements in the set (nodeNr) and - an array of nodes (nodeTab): -

    -	1for (i=0; i < nodeset->nodeNr; i++) {
    -	2keyword = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1);
    -		printf("keyword: %s\n", keyword);
    -	        xmlFree(keyword);
    -	}
    -      

    -

    1

    The value of nodeset->Nr holds the number of - elements in the node set. Here we use it to iterate through the array.

    2

    Here we print the contents of each of the nodes returned. -

    [Note]Note

    Note that we are printing the child node of the node that is - returned, because the contents of the keyword - element are a child text node.

    -

    -

    diff --git a/doc/tutorial/ar01s06.html b/doc/tutorial/ar01s06.html deleted file mode 100644 index c710b98a4..000000000 --- a/doc/tutorial/ar01s06.html +++ /dev/null @@ -1,35 +0,0 @@ -Writing element content

    Writing element content

    - Writing element content uses many of the same steps we used above - — parsing the document and walking the tree. We parse the document, - then traverse the tree to find the place we want to insert our element. For - this example, we want to again find the "storyinfo" element and - this time insert a keyword. Then we'll write the file to disk. Full code: - AppendixE, Code for Add Keyword Example

    - The main difference in this example is in - parseStory: - -

    -void
    -parseStory (xmlDocPtr doc, xmlNodePtr cur, char *keyword) {
    -
    -	1 xmlNewTextChild (cur, NULL, "keyword", keyword);
    -    return;
    -}
    -      

    -

    1

    The xmlNewTextChild - function adds a new child element at the - current node pointer's location in the - tree, specified by cur.

    -

    - - Once the node has been added, we would like to write the document to - file. Is you want the element to have a namespace, you can add it here as - well. In our case, the namespace is NULL. -

    -	xmlSaveFormatFile (docname, doc, 1);
    -      

    - The first parameter is the name of the file to be written. You'll notice - it is the same as the file we just read. In this case, we just write over - the old file. The second parameter is a pointer to the xmlDoc - structure. Setting the third parameter equal to one ensures indenting on output. -

    diff --git a/doc/tutorial/ar01s07.html b/doc/tutorial/ar01s07.html deleted file mode 100644 index 89e0bdbdf..000000000 --- a/doc/tutorial/ar01s07.html +++ /dev/null @@ -1,30 +0,0 @@ -Writing Attribute

    Writing Attribute

    -Writing an attribute is similar to writing text to a new element. In - this case, we'll add a reference URI to our - document. Full code:AppendixF, Code for Add Attribute Example.

    - A reference is a child of the story - element, so finding the place to put our new element and attribute is - simple. As soon as we do the error-checking test in our - parseDoc, we are in the right spot to add our - element. But before we do that, we need to make a declaration using a - data type we have not seen yet: -

    -	xmlAttrPtr newattr;
    -      

    - We also need an extra xmlNodePtr: -

    -	xmlNodePtr newnode;
    -      

    -

    - The rest of parseDoc is the same as before until we - check to see if our root element is story. If it is, - then we know we are at the right spot to add our element: - -

    -	1 newnode = xmlNewTextChild (cur, NULL, "reference", NULL);
    -	2 newattr = xmlNewProp (newnode, "uri", uri);	
    -      

    -

    1

    First we add a new node at the location of the current node - pointer, cur. using the xmlNewTextChild function.

    -

    Once the node is added, the file is written to disk just as in the - previous example in which we added an element with text content.

    diff --git a/doc/tutorial/ar01s08.html b/doc/tutorial/ar01s08.html deleted file mode 100644 index d0f227e5c..000000000 --- a/doc/tutorial/ar01s08.html +++ /dev/null @@ -1,38 +0,0 @@ -Retrieving Attributes

    Retrieving Attributes

    -Retrieving the value of an attribute is similar to the previous - example in which we retrieved a node's text contents. In this case we'll - extract the value of the URI we added in the previous - section. Full code: AppendixG, Code for Retrieving Attribute Value Example.

    - The initial steps for this example are similar to the previous ones: parse - the doc, find the element you are interested in, then enter a function to - carry out the specific task required. In this case, we call - getReference: -

    -void
    -getReference (xmlDocPtr doc, xmlNodePtr cur) {
    -
    -	xmlChar *uri;
    -	cur = cur->xmlChildrenNode;
    -	while (cur != NULL) {
    -	    if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) {
    -		   1 uri = xmlGetProp(cur, "uri");
    -		    printf("uri: %s\n", uri);
    -		    xmlFree(uri);
    -	    }
    -	    cur = cur->next;
    -	}
    -	return;
    -}
    -      

    - -

    1

    - The key function is xmlGetProp, which returns an - xmlChar containing the attribute's value. In this case, - we just print it out. -

    [Note]Note

    - If you are using a DTD that declares a fixed or - default value for the attribute, this function will retrieve it. -

    -

    - -

    diff --git a/doc/tutorial/ar01s09.html b/doc/tutorial/ar01s09.html deleted file mode 100644 index 2987add33..000000000 --- a/doc/tutorial/ar01s09.html +++ /dev/null @@ -1,63 +0,0 @@ -Encoding Conversion

    Encoding Conversion

    -Data encoding compatibility problems are one of the most common - difficulties encountered by programmers new to XML in - general and libxml in particular. Thinking - through the design of your application in light of this issue will help - avoid difficulties later. Internally, libxml - stores and manipulates data in the UTF-8 format. Data used by your program - in other formats, such as the commonly used ISO-8859-1 encoding, must be - converted to UTF-8 before passing it to libxml - functions. If you want your program's output in an encoding other than - UTF-8, you also must convert it.

    Libxml uses - iconv if it is available to convert - data. Without iconv, only UTF-8, UTF-16 and - ISO-8859-1 can be used as external formats. With - iconv, any format can be used provided - iconv is able to convert it to and from - UTF-8. Currently iconv supports about 150 - different character formats with ability to convert from any to any. While - the actual number of supported formats varies between implementations, every - iconv implementation is almost guaranteed to - support every format anyone has ever heard of.

    [Warning]Warning

    A common mistake is to use different formats for the internal data - in different parts of one's code. The most common case is an application - that assumes ISO-8859-1 to be the internal data format, combined with - libxml, which assumes UTF-8 to be the - internal data format. The result is an application that treats internal - data differently, depending on which code section is executing. The one or - the other part of code will then, naturally, misinterpret the data. -

    This example constructs a simple document, then adds content provided - at the command line to the document's root element and outputs the results - to stdout in the proper encoding. For this example, we - use ISO-8859-1 encoding. The encoding of the string input at the command - line is converted from ISO-8859-1 to UTF-8. Full code: AppendixH, Code for Encoding Conversion Example

    The conversion, encapsulated in the example code in the - convert function, uses - libxml's - xmlFindCharEncodingHandler function: -

    -	1xmlCharEncodingHandlerPtr handler;
    -        2size = (int)strlen(in)+1; 
    -        out_size = size*2-1; 
    -        out = malloc((size_t)out_size); 
    -
    -…
    -	3handler = xmlFindCharEncodingHandler(encoding);
    -…
    -	4handler->input(out, &out_size, in, &temp);
    -…	
    -	5xmlSaveFormatFileEnc("-", doc, encoding, 1);
    -      

    -

    1

    handler is declared as a pointer to an - xmlCharEncodingHandler function.

    2

    The xmlCharEncodingHandler function needs - to be given the size of the input and output strings, which are - calculated here for strings in and - out.

    3

    xmlFindCharEncodingHandler takes as its - argument the data's initial encoding and searches - libxml's built-in set of conversion - handlers, returning a pointer to the function or NULL if none is - found.

    4

    The conversion function identified by handler - requires as its arguments pointers to the input and output strings, - along with the length of each. The lengths must be determined - separately by the application.

    5

    To output in a specified encoding rather than UTF-8, we use - xmlSaveFormatFileEnc, specifying the - encoding.

    -

    diff --git a/doc/tutorial/customfo.xsl b/doc/tutorial/customfo.xsl deleted file mode 100644 index 1ea824721..000000000 --- a/doc/tutorial/customfo.xsl +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -0 - - -1 -0 - - -2in -2in - - -1 - - - \ No newline at end of file diff --git a/doc/tutorial/customhtml.xsl b/doc/tutorial/customhtml.xsl deleted file mode 100644 index 4837468c4..000000000 --- a/doc/tutorial/customhtml.xsl +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - -1 - - -1 - - - - - - - \ No newline at end of file diff --git a/doc/tutorial/images/blank.png b/doc/tutorial/images/blank.png deleted file mode 100644 index 764bf4f0c3bb4a09960b04b6fa9c9024bca703bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 374 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1SEZ8zRdwrEa{HEjtmSN`?>!lvNA9*>Uz33 zhE&XXd(lylL4oIh!GZnHecj|txT>yO8>^qY%(y?B;Tppl#t7yOYze#vq#8^aMzDZb YLK^d5CO(feU_df>y85}Sb4q9e0BeC}X^4DKU-G|w_t}fLBA)Suv#nrW z!^h2QnY_`l!BOq-UXEX{m2up>JTQkX)2m zTvF+fTUlI^nXH#utd~++ke^qgmzgTe~DWM4ffP81J diff --git a/doc/tutorial/images/callouts/10.png b/doc/tutorial/images/callouts/10.png deleted file mode 100644 index 997bbc8246a316e040e0804174ba260e219d7d33..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^JRr;gBp8b2n5}^nQWtZ~+OvdJMW|Y+^UT?O-M{rKJsmzxdayJ{ zDCQA!%%@7Jj$q%-wf8e0_jRx8Dqi$}^?K=?6FriQFLv>>oc^CE+aVHhW3=nZ+fQ4!M=ZC7H>3sl|FJr3LwU zC3?yExf6FO?f@F61vV}-Juk7O6lk8Yg;}bFaZ-|HQc7Azopr01?u8M*si- diff --git a/doc/tutorial/images/callouts/2.png b/doc/tutorial/images/callouts/2.png deleted file mode 100644 index 5d09341b2f6d2ea2d1d5dad5d980f14b4b05dfd2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 353 zcmeAS@N?(olHy`uVBq!ia0vp^JRr;gBp8b2n5}^nQxaY7e*=hH)_rZeB4|imU1$R#1`!P>&$poQl;nzm}mD5ZFopaX|GsS%q*{P~< z;WtmO%lhToBL0i}yfkaOt?EN=nkLNGuU`ywhI5H)L`iUdT1k0gQ7VIjhO(w-Zen_> zZ(@38a<+nro{^q~f~BRtfrY+-p+a&|W^qZSLvCepNoKNMYO!8QX+eHoiC%Jk?!;Y+ zJAlS%fsM;d&r2*R1)67JkeZlkYGj#gX_9E3W@4U_nw*@Ln38B@k(iuhnUeN2eF0kK0(Y1u|9Rc(19XFPiEBhjaDG}zd16s2gM)^$re|(qda7?? zdS-IAf{C7yo`r&?rM`iMzJZ}aa#3b+Nu@(>WpPPnvR-PjUP@^}eqM=Qa(?c_U5Yz^ z#%Y0#%S_KpEGY$=XJL?(l#*ybuErX#^g`ttQfwn3r>K)tuC)r#2`iJ>Prt42#Ndx#Uc~1)>aw z3jE@Q4|!9Z%lVv}- zc=48cF7H)t`(Ck`^+mtha~Np7bBSw2NpOBzNqJ&XDuaWDvZiNlVtT4?VtQtBwt|VC zk)DNurKP@sg}#BILUK`NaY>~^Ze?*vX0l#tv0h4PL4IC|UUGi!#9fLzfW~Qojmu2W zODrh`nrE42VU(7fm~5G9U~HM3l#*m_WNcxOXkuzEX4g z+-vfUhb0A>b04=Im{6XiQd1v%r%>h0$G8U7E1If8OQ!N~xOYY5h0NDT$p9(iZ?Q&e z18-(+l~J8O`)kc}e&uL$eW&>P-#`~Qm$*ih1m~xflqVLYGB{``YkKA;rl!p+yCFkc(+@-h!Xq*<< zxXkpt#FA2=d1VEBsYynrsitN|Y01eJ$;p;U#>wWX2KP5v&I9V=1L+C? fTFYQ)RAFeOZJ=$?lDoSWD8u0C>gTe~DWM4f^}upZ diff --git a/doc/tutorial/images/callouts/6.png b/doc/tutorial/images/callouts/6.png deleted file mode 100644 index 0ba694af6c07d947d219b45a629bd32c60a0f5fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 355 zcmeAS@N?(olHy`uVBq!ia0vp^JRr;gBp8b2n5}^nQ*)Bra@SU# zmiz#bR~{$s2si{S(aY|Z}Vd7tb ouUmn-_&~Y>fYve?8dVq?X&Y!8wB+ut1u%w%U~xZhnMEEs6JbBSw2NpOBzNqJ&XDuaWDvZiNlVtT4?VtQtBwt|VC zk)DNurKP@sg}#BILUK`NaY>~^Ze?*vX0l#tv0h4PL4IC|UUGi!#9fLzfW~Qojmu2W zODrh`nrCEbVQgk$XkwI@Y+{_8nv`N>YGIaQkz#0QY@Te9lBQ<)awbq0A4pdK&{_sV bqY6VKZ3AtCmfYR7Kp6&4S3j3^P6u&S`V$cAh@R~F=4@V4jxkzlaQrcFYWK{)(`o5XZnut z=nE4SU2g1ZW%;@@I$>_e3F8a=8WK~|CVXt1DqisQxtIX|`YW_n&?Nh#1gQ}d)$LrYTw(_{nVG)tp2V+#}WG*e^KRLdkoLz7g? qn(IA84Qgo42`r6v<+Hvch>@C7(8A5T-G@yGywn*$#_oy diff --git a/doc/tutorial/images/callouts/9.png b/doc/tutorial/images/callouts/9.png deleted file mode 100644 index a0676d26cc2ff1de12c4ecdeefb44a0d71bc6bde..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 357 zcmeAS@N?(olHy`uVBq!ia0vp^JRr;gBp8b2n5}^nQNRqa;^5&H%t0&v*|C|wdb9$wI zR@+N9#RIowg@Uqn&z-__Tzhhz!sG|vTxA7?=O|Y?u(d4T{!RM9c7chr6d%1?R=i16 z?@Ic{f32YJFJnVhX)qGzOMplv!L->5yAlT#}irms+fsQd*FoSE84k zpF44v;trs3T43Wc)AJHbN`dAXo0u6Hr<$gkq?lM38ycjV7+5A5Sr{ayr5c%-n;95g pF*H#D>f!_G3IJNmU}#ifXryhRZP1dtyA~+J;OXk;vd$@?2>@J{cB%jX diff --git a/doc/tutorial/images/caution.png b/doc/tutorial/images/caution.png deleted file mode 100644 index 5b7809ca4a9c8d778087522e5ce04b6e90099595..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1250 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbQ|Pftew|C&U%V<=|it5MYpyU{F+K zFf?Rva$<;zVn|MA$j)XcE@r5%W@u>vqT-$&hMpcE*)wGd!;~q-Q>IkUnZqz=PVt;M zK*p3gbLK2v%CK~4^3tV1#?q}@8MbbX+PXD)>(;G%_cH9=n|$sZ!?|yxmE{-7;w@N47?rU=3X_NkV zU|o{PnRTZ;lXp4>+)hZU_|Lw%*va*6=<@jI@BP^`_OsZ?pZg-2AaGf|;i2L0<>du@ zeRrO4er03}pLSxdREd>pap^;~&E+}=JYKy#vHnLI=Z$}pPyA_`zG;G~<$`Br2do;7 z$Heivv0AeyJYVI({@6?X6r+V~XS2Cs!|bddDqJz@2lKf$~4dA1c%lfOT+5KMUSWi#X5(9ePxx_W1Bsf2+N)z4*}Q$iB}K{RAP diff --git a/doc/tutorial/images/draft.png b/doc/tutorial/images/draft.png deleted file mode 100644 index 0084708c9b8287c51efa6b40b8d492854191455e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17454 zcmXwh2{_c>_y1e^C}m43S&}RzTQstU#!g0*n6YJ1aTS}>RLe1z8LVo z`rtm$Vp5JW1|R$HTrs@@LGR)Z?>PPkL8l=j-77Z&G8Tsi{RV4sPaGi)BBI`)`R~Q` z*=O$N8oBahuA1ujq=ONsH^Z$;Z@?A2zPOR;+t7%GvNscPQvtyu^ z^(He{(TNfAz{D>S76#pNt`V=aFm{t&tF)Lut!iq>3RU|!!{xbB|2@69Az7({KpgFX zBHUL)|7ydZKc0k%azcGA&PuCQV*kD$bT{P;b?=`M@6C_|b6!~s9j#tuU~e9n-MCHj zfV5S(js_`kv|ivaLE*6pY!G%r11u^qOVBw|g29`m16#D?@yi>zc0bwz%G@ za2kvxn$XS7{2WQ_ju!==VTs+`V&L;sVz(Pl4+J?F&ZZv3KoKW2c?bBtGq5)oRM?*)usx_-H@47Cu#_qL+2eow%ZDy0=bsNsUP&ms8wSUp@nG86W_bQDmNMRgINC`_}NgC zCcqF_Ta|ScVvPu;|0KG{NIio~DaGYcHYq4AEiIzkxEPqs@0$Z$*)*@J$yP3ObX$%T zzRS=t%7(g3t{Q*^ zEyTxT$*5+N*(plL90Bl6`Nb^WdKn_Pvpb{prO$Iu<5}~-EnXK7fy@_2c89d+ZhJ|)%qTOcbj#K2|l1B!3n*4em>_| zs0+)H9*C!kU%yVP5l({XnQMeRu}L5Sj@SNhX<@4AzfhMZW{P&$t(3w4cF;s3a!PkRM$$6I_u>8qK3>fr(_ zv-Y*v{SjgTfq|+BcyYvbM!vF^@bCsN)N`rpJ$><_Gs5*qVfQ0@761Os;NFEBr2V@4l75H}1u*H-x1FzIyrv zX4-neRxZt~y^&-x>*hYlIJHqt-rL&^c9<9eB-5QN-kNin&S^e!8s9rIjX$~r#FHSZ zPPGHSJ7NH?>J1WXHMp6{3_m_JHFb(pJM-&G@!UzwMZ19kYDMv8^_@35=1Qp*GU^C$ znS!nuvPQ5{W^@`l=K{0vn9d5B4sd@GNsqwYt13N;s_n$M5sF(Y{Gu{$f)Pqq6>`4( zoK6ZojptUz?t{2OQ@f4d24!GwYi6y465k8gmK^#vxd{Il-lBt^R7pE@jfteJwgkQ(YBxT%22tXdci&(7P>~Iov zlAF+-uyinD*mU_C1!Z!%vFE`wQx$H0WX*IMeKiv()c!!|Br&A#iWksE5wy*|X}DYF zOkmbb)NtBhwAgAQQ)W7>BzBj)^ec8BETv8dt~1Wtd}pfRmKnoYyMymV`fvW*bjTy@ zNFqchp{S-_%)XBfUmWyYYl$xVgQtxEVn358@gKtpQuu~+-Kl-33E21oa-Fi&oBI&`1N%T=`T3uD7xjR z1Q5DaVd-rOkkqXdK@Yti1APh3TN{S1DknOaE4Vdk=o-MQ!`zf#3^vm0RTp!s>(8+I z(BKlybb>#^&dE#xTWKkB5>RG$`5m60nzI~B_{R+DtsN)(K1(tUpuVHL0)mIKnUfCR zGE=xGXN@3g`N9QSG|T0c&wxuu*Qg<*+`PlfSfJAKfkWnRsVJ$bx1$Z`o)r~6%k4&i z<9I5}9(ypb2w!#-r7*;K+DjakI~Af;0mNtDxBc4R3|&8W^=h6KIf?>|@$@)*tlfRZ zrCkhM8ZMxnVd%Q>wKHQ6h;cwwxcI6738osp@h30JoAC1Si}3tS%4m{iuKSkF9xsrA%;wLv z8A#j|uifcVGx>ptY|-u;nJ$&yw-19u5smA=3C-sC-n~XzIV= z*~{{V0<$*x$DP?_zs?b?-Dsw+U(_(rI4}YY;n`g??R&MWiSNSHJ{;g>QuE+91GpRE zd9DfqUKVfdeAUwO7il>!iH(N~Y+WTTbX3b$$01o$aei(SD8PN9Ig|tehF6`&rMrwH z6C(}UhO7r4V(nXd&uyraV5X$iUUKSF7E#U?bu;$RHwXn03D2wdZR{}kbxlVH%&8F=8tR+X zZ7kKlMpt29EK0Mnb~Bm{1y*D227__FT~$T7>%Bs>RxQrlgI55^$os$sc`ic?+hwHQ zy%C%qRZZ?xjTT>R%HJvzYPmTbNJa&lc4N}*?d^eJ+TgWWrby|-X?$RL63$ocD0=1z zq>bD(K@l*w5V0aAqv-^DtQq(*B!;KK;S)?XERW0Z8_eB7>{FG!W0Tmu$$a@l#~e@t zb7eAjZ0Z_IN~+HjldvP|xLYiL+|mn)Q;HmqDMG^&^)mW(%Xyb~AG4Jkd@~F091U{i zRg(Zi(!S357h;^+d50bWLHO{(l58O+_d192vyD-Oh|kx|qkk|71w!Jdg*R ze=X`e#>jQ1n83%L37gJmxi{uYC;jRU__qGnk430EXC8CcRU^h&pyhVlHM8x(ce}=L+^|Pv zi|35MNQw6wsl4bw0P{NiUo&-{is+V{iXV*G{_L^ONZ@`H!#JZ@}t;bpd`Z>sx8;y zHg4#YSJ*anpi2Do=jWPejhaoGWKx!&jJeOVaku|#u8?8fCKc>EQ4j zn#0h@X_`cW22kHot+mSQz%;tAI|=i92)Mglsf!Nu*>=_g&(G0d>km#k&)3TllY#^u z02UV-NFuEUi@}-x=ETTTKA`X~EX5jv8~B<}HTK+*9&OvU2dkm`_BX*1VwV7Ij{pg= zxZNaUqPlcVYHAyHFof?m;I-ZD4bN%(@@2Td(VgI3 z{*lWmv$RZ|smov=_kGDznn+>_uX{A6;y}7pk@d`(Lh6{gFvrA5pAdMmu#G*QM1tQg z2^Fb6c;#}e`;nd&oQKh@*-zW!9ICOL;OFgA2-lpdOKmA=Bp;B_eB?c_df>veT)HW_ zs^sQQf+2B6j;5$>ZG`htEUcU*ioNkd+t(slRq00x_hk@N@P79aTAmlqe^(+dfnlOAm^WQavYofR?D70kyE!Q*mr z=MN`!PH<&(t6*5^bfSkgq80c+f6zkhX=!PVf1h^9o$GPX_wJAXim3%oV$)U9uWEOS zFZ=#iF~Q2FVvon!cVc(IvVedI_~ko1I5_AWe$&m4Pfz2dCm|J!YrHng`j<_W)9N6m zB@dJSV}^c#gL?<*=59v;JS=y@jX-JNZOq4)l)5={d`D-W!H@43<=pJ8Cgd+PhIgZ0 z&1}v2D7JC5c5m#$OqX|BP;TfUn_N`fm(NOG0@Nct5f0=5t?)gK>f*TZCP8 zE~vAz*f8;aNltIEzGmjk2?*gK)Xp4zr=6}59u!nRQiIH`r`BWA&&b%MJ+5|@JL))( z@lrFw!p1WBNbZB0IBSb692ygY3^VVnsCLI=p1DJ|9{R_viTo;ObrMJc9HN|9uopn6 zRxJ;a=NLyqW+8?@vXq*8_pkle?wWh-VSoPI3KIY*(nFq-Do;;Op#DRi6cuGIH zS7vFz0{w!T_jHtX9_!if-#4x3C9rYkU+2(KU|U3m|Bg{GCEc)G`)=}$uCcQ=o5}DE z4Qf|tZ$U3T&S;B0h&i3`PkyvL2&sK4L#)80)82naNsAnG!T4hTE7tIKfou;^sdejO z2^s6dG*bi~@XEf#g^+->YY)^i=j)rM{NpB6Os``bQrQDn`1IcCuH_tZo5u_RDCH9} z{A(qdv9-0;w%911g+6sdttId7K8LSzQx$iqDz9QJ%qEV5yOmP%C1^8VJ~&}mU03FL z5oO`+?_NbVx$89Jw_-65lS!LLL^<~>akOrQ*k8YT2f4npv!ne5LrBe1G zio4QV3V(pOPhsqCE2}mF#DXWKYCS~L->zo*5E`io01;dT5!%$~no!XU5w!2{HcD?P z$hkcJN$uNC-y%aa0(KSOy?hfCDA$n{jchN?d(tgsICQ1t%qbWQv5cv{T zBj3*W2{Wy5d$(v$@2djHMZWKG0-|MBp}dhVgo z`Vtvp{;P+IYGFXmo{Vm!Z+%cSOfN(pk`H&G(lF_arZgk!S9%x!bxKv`i?_8}mLXr- zfr-&54|LC~#MV?wRQm-EFSRGh4UA`d#pe!1bE-N?4{$Ro_JUO#b#A&ZN*AR84Q}u< zvAY2P2=^9%#QQFnV=U#iNT(o73@pmXuFN9 zR?J5~@ZQvv3RK1HlYa(JZ^_%8l~?wwv#lhDjuMeJDC(xS8@gFpX*CRJe8FTVfJFLE z`L1aE-QBK9wh8Lf=pv(3olJVvrY$Ug*U6Z?{29OF(VGVhgGPXNls7&Qa&U0KV+QnI zZN%rly6U%&wr&4qxD-ujjGO;@!kTH7t&RXS%qN%jTu85~jgj|mC`qh(pxU=LV<8nb z2*g-&X|S0`7pDK6F8O&>ow7=M28`!FRi!}mwg<&m&wRfJeJ}DJr|iWg3+r~FUb+VH z+^&Un8v5io|7I+;!f+OL&4~5g{fgrz&*uKPkBlbI#PEevl|9*Y;=ZITUOO{Xx3C?Q zjzzGgf??gQ$0$6k$=bjrn_FR?Ye1m&Alpp zIR2qAum=_rBrlX|_n?Z@`qf(Z0Kxll;~uBw&`7z9Rouxf&+){$ zT5l^SU3Q)C3!P4v<8`92?@GD3FQ>)aS@lWl&S_BItaudFE*~l)`|-f4TB#FImiY-_6&9CJ9!>+TEFxeaHO)c zvYblCdx~?kBnWI3y61_CZ7mPPn2!+y?I{+aqiJZV?FagXcV{P$qIQQ}eE8YeF~}-C z?~`EwR@Cieg6$PyJheqdg_twn9zXuoot>29+0UEtNnjKl>TgTSUIvF?r06FMW=5%U zVd7m{^kQJvRLT(~FbI!5QPR|t;QS06HwuN4s*dj5LYaTRDxc}ZbrgWm^`&@BlD%v{ z@k_@S)~9!76hB8Mu>D387Pt4nO+z=`W~vOK4w3_J5I>vM30q#&d2?0jd#W0;VqxAg z{*lOi191%V8^8z#kba|g@ zf4GgGK?gk~`S@>iRci6!kr&;RW(POG$iTAEX&_W3#)}zCBeQ12R}+C0SYWFB65117 zYx=X?gFD^+O{W+m*yAfTKmH~iyJk_ORwrFE`7|!~oOPP-{gCa4!U@A4tRgdFHX_Yj zXQ(+MhO_<^GRY)^`TEi#V?93xP#4UrcMTTD68zJ5m{DboqT=!RTMbx!3!QK?HvU2k za26tqP;3Z8*MmUwL{1I(@xTcd(1T(ot# zQ8@|QB&oA%VI6gn^=!_v)SeO)d`3{ewC>T3XM2ZqXV?iJKc$ft~<<46c!aV(J1mq1tLFMB0Q_){R1qliEw)EIh?S*NbRo*>YaPx z2D-q!@M}X!8+eqQe9(&`vcyr9*&Oc9DxIi1?hcoq6i$Ah{XCaH^2(3TA1)Kpu+!qk zA@V)hERaLu1FN%*CTT?U)U3}+-q2_=P0!NO%*+f=0%Wimi9$O7C`K!{L9kB*slT?q zUcI7*#C3?0;`R1E9%YCjZ^&A%sl;VB6)!NN8!ilSF2s{jaYk8%7*iwJVYB!}O?`NH z3i_o?`Ay@F!YSHq7T_a4Hx}qC1`Ys?_byXR)+^(UW^H6<{Jzm;NPkU97r0{^fT(G3 zA;><1llKwo;%)@{#|9*KE2Dmt;(B|5Xn)(d7V2nr5OXUnA1y_!SW`EtahHzmtl7EE z%djW%*H&HXZ5G=Zciw~l@@5<9~SRg`>1sdv54 zxFT-jCM&GG@`Q{Ed)0jXg#Q(;FzY%A{D;AwhdaxE884#bo;|{{h3OhPo0zbfk;Dak z&K2NDkc8^wVPB=SuB`+^8?cY^RCi~h^*4EmEc?J58r@|g3@t=ykaw*U{ z7v;3}@P2CDd|+0TV}fa|3wl21cs|OFu95chX_S0!)zbD}eUfC(!|&!sVnQ$17U~i3 z0k=jQ+>~NKF!oc>Kff(i>j!z@pZJbZ5Qp)A$c?DsJ8AAv!O6p8|34Q%YV*_nJIhup zmQ_{jUUf_x$nzc!4cNy^2`mY?*);JNgVn<>CsVJYluh4fgd_lF1||t597+ld|`Ww&*4Hb;}rzPmefkY`>P)eSO9!dk2T9lx>3Nj5=Mz z>r&3-+b)2!U(?WAgFX*rf@W9Zs)AS~lgtt0D77}&rQM~)i0CR!i>JVNn(;mN6vgZBRDJTdsnC?L>2H3nvZSp}#S z6*9#|of{57Sm7ktIRid*9b3ZPg&%fX92~R}5M69&e`W5`q8wIvKfBufD8f~ti%ujG zOKrw=EiJwBQ@H^*Kw5USk7cR`7;^B0t+_@D3FT&XdE}c8tK%QmNSn;A8RAsMn%(|0 z_}jjAHPj3;YFouX*X_FojE7Cjxz=b5i*s)&Yd&bUzA+NKT|Zgbdbmf54f|QjdK38q zi<5!1eI+@#xyQUC|DfNCc{vl9E=gF^==yjQil0#7c-)K`hM1O%+v4rCu<4wKEeA0> zEp7n)lZbgQlME&N{V?)eCoEp(d6K!Ss;kAyp#QBJcej|g)B$R7KOOkifc9VnF zpKF%Ab3TXaX3pJr!NN3W-J#nLcKyGkvKH+HgbCYH}OT?)qCnEf9AXZkAVH3MBfRj~6fiIx9-31EklLu#&A>uM1w2k;x{p z6SI?Q5Rg<8S^)#s7ktzJn2#%93?7_*{LTCC-tM45qH{l**RpP#OJ?_o|&r9_@2w=JQ0!~pTA3FNiUVF zjRt1OxG5gVaVzD&sIKBRWsLqX)%Dkp^<7D*ZZlOm3zvdK^caRuw0>+%#d)V}r&k&S9MyDr!%#@BU!SxwyIS8y<#pz4TMM)V&d^NaNs%w$r@xK#Z3m-2Z*B z!#C;VD$dR|<3`KMGMYA6xX-+QD(`rW%C9UZWiLh9%$D1dG#BLbF0BPZF6E_5rP3E_PtxKxwhc&v~_AC^KGDil_tZ4XGnVb_$U_s<> zm8kOFv>8SO#Z#<$=3;#hN0AoE1Eo}p(7cFS7Qu%^IP-@56DRm6;s!W0R~nyzVbeB3 zPAN{zeWb;hUGr&tp1Tb%L(Z#nGF@88afdvP=TZ9_k=he-T;vK+PJ?P6ZmqD(qF2)s za2N9|Lc_5Nh35`gW$V?KI?Em}*YAvfg$3DWNG(QvSZl?m(ctUi;Jj>c8s=iGQ_8IM5DCuHH6)h}yp2H=v=D>3DC$o5 zULiAntcT_b0+|=uYSp|RU-2AMnA6H6X~WBacfvSg6(!cva9ZpD*PX&B$NOGVW7m4Z zwa-Ri?VbD4_e>?M_?{Gp5;i_LZoeQ02^su&$#yDX?_v;bcFNw!ZP<6Xv&q9brr24? z|MPgFAc|V;-ru*smLhtJwEd+tn+gNbYoIlb_Kua^3mizF_sOpaD<1}%2z%fRbie!kaalVI{ zp@PyqhIH`4Lsqp;dXPhYq~D8f_H6FmSVw-c0o;ya;C8Y>viOHkmc!hn^U?c42ZCH^ zPvXs&ZghbhD2ne4J#b17FiS1I9RZ}k{S#@9{3>3owZjjy1{zN14ROf_w3vGo{JOw_ z5LgnbR;Hy3#ZJxN6{=$yTGHlT+Ef*p(!2*(M=pwq@gO`fH0Dr=&t+`4T`zSS&3H_CR^wcr&oGobo(9^R&aR88N zpw8q{)!yFVT7gxPn;IJlWjTZ@;6^gu0o~Co*Y0Z@emdc=ZP)|VUtU{c#1q@-m_(_F zc1`xg?iSXAbKiaJX8bOLsLi6+@?>^2T?51nOC5Th3E$~E6NxFrub(x#dXlO?;HtC3wTw{sEq|t|$syXv8Tfi8aLLm->hWZycx7?T zJAi@9^p4)TX$*q+{W7YJe2KLA=_$$-H9nhPJihFrO_S8hL+vnyy}LF)%0Bq3`+#x! z9*bF7ccIkdCZ@bjMt&SE&fg93dDU%csbne!aFMjR)C1<>dSOfAuTm{~rfOo&wrBMJ zi&P9Lc>oaIV)w+sO?^X8sjG-$-RvZfqbMm$3ez1Ue{7OHR`>b6Zq=_PrYSjFxJ0op{4-*e>HCa+ltbeRL&8rk zOpJhZ9$>74+^4>aDY$y1{+F~p?}C)d=kkO*yn}m+Ajw3dOKVp@e;LX1bbqRk?i+lw z|D*uJfF@Z)tVkhWM8?V&E# zyTmdhV1UEb^kae@-je}deN9LG-8T#3h1#ojCe(gby>*zW``~(Lb6U7b%MwpdqEq(K zEAS{$i7H)RbG~^`>SjFQj+Y?^Ft_1`?au+^$%R3VO1zaZ&?NS4Ry^!zZ^1c#NF#h@ z0TD8T#jmQSaL?JG8@5uub}qy}n+?f&XZkDn47o*x8=R+CS@9|@+5Sc{deuI{#-k@8 zGwVmk8dyt-NdoEExb}uMJCH}0UCrJi0uMR>5}ISY3=oBH&_hoY1^&b)i~yE}u?si% z-PVt&T)q;ZjLX0sQ_TA3bY0+hmGSl}+yLQsMKtH(tvC4_;^TC@vXLuNNTcgL$DnOmGiLhtBsMO^AN`&cRypL?h%J zBiGYxSf4}dsU(n)My$~2GQ(fLVZL#U{ho7-j1j?+)IK2=G zzXCkvL!y~{frb8dl#NEpiJ)7iad@m8(PH3p4?x|-%d5zWr95 z{rZdqX#)sbTEuODXWBnoDA=^8YbJDSV-L>lfASXZ8D5y&t!Z16)p2XHLUQ||$XzhY z(ZNTOhU=WEWxG?AOmpj8K~s1|a(9*t@!RB$%7U*=_M=t5`sWAFyuz~O>Pcjl@Xup- zgO1W}S3KEY&FGc`(1n6n{`G2ikZF>bki9HXRA3j<&l!tlbJ90F>rt$!$g75+5bn&= zjyM80QWmZjI!*;6oH#S|oUcV47FQsDUj%8+H$#7kjT51X^Jtx)%R6|}%#Dzl{ml^0 zsv`Nn-|Bz+48SiLI79mr$g&j&34dbw@n{EdZCF)Q;Eel#;Nmcdr^kRV94rNTeQ>Vz znJP$)fOxR055Bx)K9o5)r}JEv*;cD>C^DQx@@g87^oPS)Thwn;1zXm|@zi=;a?}5h8y* z6>(bt{|;@&f#h3nUIC~HE_8P)0gPfgF)Iz@RlCu`TI%(q~$n4sNz_?{|9BnSz}B&7{#_ zK1qBPIgO|{V&NqKX{rq+Kghb{e3jx$f^oK<{_owdP6x{tVp%vtu+-oKp~{XTyKKwM zX$Z`c@2!q%PLTgNKUeKOH3e?Z#(AjRAjfx2O^o-wLC-f~kXBCsjG2SB4k!3w&_%ssqiht1fi`gwthS zZRJxsc=Hc02T0kCbeye6=v`L}H=CcUFBS95I`opHXTIPR!vcLUKAVpo{skf;5|%cj zKZYwozQ@0;jmm7Ewzi zo<*oL>r^0lz>yz>?Cy#9!RQ(wwu(u2d3jTu6aCREon8S6b$ev_gGij5MEh0OwVHeY z3JMHR>*HK->0zGG9~TkshQO@B>eP?{hJE$f;3N>uRLhJ}P~ZraSC!2Z-m?eb14#V` z%Wf}!yyU^lkZyZXi204#!G+O?Q@ceB{!4N<(Xh3BuOxshEnNU26-F#`#RIs>N}(pBW@Si2rp;jR0tbkkeB?zr zS^vJtRoNXb>y}tW?zt}O@HIPqMztv8X1Mb1o1(k)Qcp6Pr6uU+Wr|!Hv7+$?#M_2O z8ozNt-UfLk4P2gUH6A!~G!t9m9h^|<)O4k5$cNw60eE=UoqqjQ71i%yE>IF5MMw53 zoVZpnlyb}7VoR-eL}JL|uKeGZGj%Bhl-tR>S%pT0QE3%}REJ4vlQXBz;^otxhg?Ch z8XD=ERaU!$Uo=nzVP$E_ymK_%iP6+MG{s;{Y7rF$-fQvmr}-!7R+5kFfp=OE?phks zAIRMnzl_f-n|fdFUx?=;*-?y8#j=PGKPpOOOfX}Ic6w;#a)+T)JYU|+Xv2w$zY|)U zEeeU^HM+hO--oSU>4i-+iF%MO_+IX?wo`R@!WLpS_grU1%73579~%ph(hCzw#gqKS z33(@oiGv3~@~gXqf5#i|_#YMm|B*Feu_oGLserI4H_P&w_AZb(3Isb~x3Ld2CgpT^#omehU$@8! zZ37~|Sa6Xc;y@q!+6z@#hh!4ucXrj8>Qxso@J<)u1I)@I5I^A46Xis^4@P!i0{?O+ zk)CZ~poU|sFD2L)#iE|&ssJ3xPipy!K=bolV9l|2Z(i}*43Z1Wl>m~3P4rKR z;{jYf=VLJmi^x2<{AMKuKw`P)#B;8nQBOIhHy->XNo^z$xthq*cY@X>W!5<4<@4FX zNAk9jj2q$VscrAdjGHmRtbN?guU-Ze<)BHW%*jo5k{5v?@U7yU_yhoD$uz_q-~545jZuxv;JUQ*eFqk?xfP@lh~jP(N?2I0NIZ-q zDGD#GS$Z5%#81&o5Ufv=)9xJ28~UMS`u^V4={bp#DxfwlU7@e?)*KGps|+y(T@tnr z9A#fLvb5wqpXG&eyWHhX@kN1}iO>(98#j(F*qUrT%3$LWY&VnO9gyxolrhty?u8%M zar#N)92>LMOfsB>_D%XweB1a5z8o_t7nV53zGhsGH=Ml{GE->_3^aZ?i1k+KH{Bi* zY{{urjeCUUx{4awMMqbyudOM4lcFe}f0kQxel&TCX;q8#ItaBSss?l>cfYcppL667 zS>TiWKH{ZWLw~L%seSo-t#ZVhl2DGsZb6V3qms|C<$Uq?0!WD znTe>ujm8kZr!xr(ULadh!(KEI*eP2e8ztmktEMSwD&hN43ddd7xbRW-tc40~ z19$nWlggKs>s;Od2Iq;+HaSzqE~nHmhvFSvxIn|naZo8v~4WofUl z>!4oJlcv$-(Hu&G#ZJ_w5Z)n~Rwk6YVkfc4?7^k&H4vyEOMEwEPa;GC(@sG9UK0l< zym3g}=fXdvShWk}JWOfm_hXjhW6NC8L44=y9MCIOFwlD^9541durm zIjxI`e%J5;RSEZ-PK64!Z$8JYxg)OYus$7X)=3YXtpuw8`FEZoHX-T27L3^3mCkP{ z&5K05BG=29L~TDoxs)Ze8YnCtB6r6s5%IM>J{E>lKnexjk zF8wpQnq>*y(C;*VyBSQLL0w@L?tQ?-PuO>uDOcCX?6xMc;$ZyH<_&W`uj1gXTP$N^ zG4Xa31VfrYj;M^;f(-Tw`<_7wa3DmU;dQiQf z7NxutM)uz=k#Ko!M0*iv^qY@@ibmclp2|7Ykd5wdL5{;9N3m~n4g=tUwe;P zI25w!A{9r;$eMW>q{hpo19Bk1pe=P>6r$o%=>7_cjN&Tm5M|IJuUvH+AK${CJX4oU zgO6^=eBKAuGz|tm+nSrK8|c$@b06AJVIe41Kb6p*)`8SjV>XRLlD=n zxmF_SZPNO?HOkAGmreqZP`zhDat0zvL6TUJs#jj+mv!eE2D(4H^wQ8v?J{{F_uNf{ z3Guwlmr_Y+?1xwv+DlCV!Qxf3`85lI9<3MYLPv#eKnDUu^wHQ zc>gm5549XSAWHZ;ccVn65dF5Y_!SFO%Z|}Q(6SZUI=Dtc;z5Ty%nrLYb#L*-Yh(x- zSIj@A+IWZB(0~zQg=&PNK%${P5hZ>29oZHuVGWHXY$x1YFsQbXHgN={wk@*qqJ+Nq zd)egXY~a_ZOiJe;TU+HKlsyJTMfblt8%od5*(H)*Q$D;z+^%AQ4mXPuX2k}%-4;79 zmQ1FAba2Ra`Bcxdj1l&?kFD%K^S3JRgKXK4^qjwecz_P2uJ-l zC)Qvqm+~M!v43_gwKDlR1nJf$++0o6yE@XCdZL3q)UgB#ypJ#vJ8S*1wxK1+=6B}+ zXR*cqf>giPZZtBQvI{Zak5z&s<%W6@C}Kc7|Jd$GBC>hYST1Qs6_hTGb>DuR924B0 zN83(4+CxS$>H&|*-r;Fo4NfL83)iN!YZ&TeJH98$Hv6Ebv4bJ|{_ja0c;iH3BS>3^ zpqgshmx8R31o2gdvH`OqjyW=UU6imxAx*C0^Zy99KL{oAvkpUJI(*CnkaZUKS|miv7yJG9ATWhm{X zmhwPou-YzMm|1!Q!U)jjx%z~gla=8UD)w?G&Zaq~DL{YDwlSN`Dnf>gnqOEH6`e=5 zK`qGvB4v}6phVXVBt;`Goq9`6$1(ekF#8@rQR!O?lVvgou3PA{Mrgg$a_qp=fEaM+ zd)RS3^IyJ;lNL~f*%#*d`QhDdtk^TrNIS|sGACrecpC80;-?Fs23-ZoFWU}~?O7@t zRJMKubhf|4AK65+^Yw8fyef3O1aA8v$s3mu7PHe^U+V4qu@K`r&lUl#^MSr$PX__o zkc4H6xZrmj{B9ymd8uZ1l@104i9rzScjn&(C@ri42@jd|ET?03nMCrOz62_&EiK<& zSBCb#CxX4Kax$9yU;Qik2A;XS4l0o}3esA}H7YGS`LFZ+Cp-+Ao3iV`;Y2#t+RBw4 zx0Nc0Q9y%mXU8X3P%JXaJSA=%)~{Chg+d_{`+@cih8jx$RRzetz1P5XI7rt8+K9*g zkSIZ8rn1WK#9AdD3qWOXE$*F3Ot={(vVp^%iu~vZN~NYgy8_O?l!!1aW}T^|BNP&6 z0?qjrcZN zmjmPbA_FH7lrCAL1d^70)DpX)@;aCfO87MXaxB1q=%jAw{{D`eJ!d-BNT7BMlMWP}{ZZ&o`DY!}ep;HhTV*iZR2Rod;vAPt=MM&iugW*ReqJUt5Qt_q8>ioMMBX>R9!hDFUD-8$eYs z1-TtSGqXUHgLC2i8u*t{Y|w|+jMebIyJ4s^A?cD}pz_yAd)%*nkt{$;7Zl-taBgGY z3@mR5iYU7aF`|s8$6+Otgv24;=D;){kh=%;5zgNp{HcTraHisq6ZRfb zGW_De>QlN^)>%P;wg-4IfgjGe)9@8oA5f2u;i&iuD70ZYZG>GVyG?KsVh7^@q^+_&<9k|1f{n8Ys}&4 zar=)5U>;^OAAH~;qzbCyEiJ*~gbv|vsZP*7fI2Zi@i+OI%Qu*&(tT@erO6Mb(Z$59 zguP#oe4eqid_2;#q}qW|`vO7O$`jJe$IvZwKK6c?Xzh#3XO?(!b^2k4;!# zYGW=JqVe>I?z~`PT4Q2xwFFNu6ey9UCv31nPenw9f8bRc#Vg5bJF+YgK;aIo$ualP wqI_@;Bx5sQADwv9=?)5}0VhV#cC~Kt`tEf9DgFWeNC#x3htMsB-+J`_0Fi|iga7~l diff --git a/doc/tutorial/images/home.png b/doc/tutorial/images/home.png deleted file mode 100644 index cbb711de712dcf06597a3a8a3d95f6fefda1f245..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1156 zcmeAS@N?(olHy`uVBq!ia0vp^%0SG|!3-oLGuzY{7?>FXd_r6WdIS`E6g8)48qP6v zn&afP)GK*ya`E2cmc1=K$9krmo3ixW(yjNl9=mt!-1BqS-d}tE{`vdw@Bfd2(GVCG zA@J$l5_e#hU`+CMcVXyYmGuB}CVRR#hE&{I8+eiLumVSprtq8v761QlTpYPgC-&05 zDJ{&8o?4V1EYqU7+)vOI#yLg7ec#$`gxH85}f}H9d0^ z(^GvD(=(H^6-@Mu^ehxCE%gm7^bHIZl8Z8nODY|5D~n4qll4-I^-@X;^7BgclJj#X z?o!+VG)@a_TxNP+Vo52`JVR3xV`HP#G)t4DL{lRpBV!ZeBojj;vlKG}W79NC!#D3= nHUM?;fpi4`tz|GatuQpzHqbT@s&o4Ulwt66^>bP0l+XkK0lack diff --git a/doc/tutorial/images/important.png b/doc/tutorial/images/important.png deleted file mode 100644 index 12c90f607a1b27ddde0a7d922ae255e8c90e883e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 722 zcmV;@0xkWCP)Gdz_qOoSb{LwMwNgp7=gl$4aErG%}mjHRWNrKOy`y@b8JoTa6ut*xc4t*y1SwY|N)#>U3Z&d%1> z*52OU=jZ3|@9+2b_y7O@tTMkk%M`~Kg@u8&dg_P^_0l3yQb639!jLZt^Lx<-O17UeeJ z-|=!77W(jGx&e#?FOku-gKofoU0$~4M+dhLFueEauP`}l7LV=;lsOdn%WHure=x;k`m0(bF&MU#) z-qv#^n8(MjB|ykioqII#+`g4no-MU=BK|Sahu_3M_-d*=7hq=~t?^}A)G7 zbairN0An*{V`DL9V>K}|HDobmIW;*pIW=W9HaTQ6F*7kTGI9=S@Bjb+07*qoM6N<$ Ef=i}M4FCWD diff --git a/doc/tutorial/images/next.png b/doc/tutorial/images/next.png deleted file mode 100644 index 45835bf89ac0eca3ad69c4d8397cd5edad2f8782..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1150 zcmeAS@N?(olHy`uVBq!ia0vp^%0SG|!3-oLGuzY{7?>FXd_r6qS{MX+1QdG|HK%AA z&M|bFA9tAudUsBZ|kvp$Id-JckTVP=kK4t z|Nj2}C>RZap&SB+ixVCKvjk(3x4R2N2dk_Hkkjkw;uunKYwyH|T!$5ST0$SiY~H5U zR{cLbR)lT!-5c|b6rGCX%N?2P<`-xxUu`gZx87&*3!~4wH@%p0)WuYX}UBIC~8cAiK_+plk!-xP|nq~%Rem@g?39waS$dFIAw`2be&`&H`~ zup7N@y!g@N+18CSR#dLnIlgB9pXN>WRz-=n38I0oRnmeW@(a^WRPZVkYb)}kZ6%y pT0bWnsEZGzD*$LMgRyCap{cfkwt-Nc+b5t5gQu&X%Q~loCIEjWXuALa diff --git a/doc/tutorial/images/note.png b/doc/tutorial/images/note.png deleted file mode 100644 index d0c3c645ab9af6318035b026dd86944b9ddc9114..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 490 zcmeAS@N?(olHy`uVBq!ia0vp^5+KY0Bp8m$B&h%?rX+877Y2q^y~;)m42&$EE{-7; zw^Ao5PC9JB<666~wbh%Oo7tJ0_rGWfi({a(qjR96>_P4H$tJl=Pxd^1p6`8M?=jE( z!hchf6<8Mi`NHe6`iia69>!lxe4C2-S>+Wvj;l63k!MNSb9|1+f-i>irDi|a^uLl% z^#-f2#pQ2lC%m~9m9JWJZL3|T8FRX>A78<>cU{Z6XGFG336=OLGkw25|29|RG_k%U z>j|M}Ih2i#-w+9_FXd_r6qS{MX+1QdG|HK%AA z&M|bFA9tAudO|H@7THL=dQiK_Wb?x_ut?D z9|fZ!FvLS(&zmEwfLVeu$=lt9p@UV{1IVfNba4!+xV3fSLB2x#g-7SkiDHi<0%5c709k4@>c%U5PUn6XiNrQ7+$BX-K(BEj>;XDjvwZcIF~ zikDl%a$|T|&B@5M-I14sdv^1r*gkp|z3k=crb$1i`yH45`zBpRc(KYI-u^rPzjiy@ zGH(5%+Qq}Yvm59P=MvY5lHmNblJdl&R0anPWlhiA#Pn3(#PrPMYy}fNBRvZROG|wN z3w;Aah2)~l;*v^-+{)sT%w)aPV!f2og8aM^z2yAdiMtec0FBcE8<&}$msnB?G|wQ- z!aOlC%^=CZB-O|yDbdi(G|ec{Bq=S?EGaqB)I9sbjHy6fd>~x`Kx-L{O)CsdwGFfl UgzDTr0c99GUHx3vIVCg!0Q2->tpET3 diff --git a/doc/tutorial/images/tip.png b/doc/tutorial/images/tip.png deleted file mode 100644 index 5c4aab3bb3543191c360387c4af9a3cbaa051345..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 449 zcmeAS@N?(olHy`uVBq!ia0vp^l0YoM0VEi-?r};1DW)WEcNYeRRlUkaK;CUn7srr_ zTcwkB3m#VBagbEhuIO1a$!w|j^feEHv@=+|woj32oF*6|l<3XH$!T}Lao)e6jJhoQ z_vr?OZVprC|7iZ8xaicUR0b&zR-JdP408=+?zC0Rn8IN&QLTWhMIcU0X8P7uUN4WB zR_?a_;&p>ll{>(OzfJ4N{OX={Q&zNgO}j31DC;|ya^r9Fjd348&p+!^cT+^sws+=& zCu*T*mRNK3PE;$BNx$Fa_9(Y=&DoXLMFRd#U31O)<`W^F&-o=xbIqK-c?mr!bmn>! zky6TW;ML~4nXw$T{yra=OteL6G!=B;0=?;6;u=vBoS#-wo>-L1;Gm(b>6x3Dp6Z*J zo|&AjV4`QFXQ5zesc&GRZ(yj9T$EW{Qt6OeSzMBtte0A>mr`1gpI4%noS!>!m*Ngk zP=bxiOwUU!DFvFBnrfM1VQy}0X_lO7WM-b2nq**TZkb|inr2~`WR#dJWc*7VsEZGz hD*$LMgOO>4k%_i}w!yxSoa=!y44$rjF6*2UngF(YpwIvS diff --git a/doc/tutorial/images/toc-blank.png b/doc/tutorial/images/toc-blank.png deleted file mode 100644 index 6ffad17a0c7a78deaae58716e8071cc40cb0b8e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngf!VDzk7iOmbDT4r?5LY1G0LBeqssYGrXgF}- zKtn^rf1vn(hW}s+NCR0w;4iG^2^42c@^*J&=wOxg0CMC!T^vIyZYBTtzyH6zKuy9A zentg0F+qV0g#~P97#OBpaJrNsxA6f`rE`gEL`iUdT1k0gQ7VIjhO(w-Zen_>Z(@38 za<+nro{^q~f~BRtfrY+-p+a&|W^qZSLvCepNoKNMYO!8QX+eHoiC%Jk?!;Y+JAlS% zfsM;d&r2*R1)7&;o@#7ik&>8{Vv?F>U|?x(ZfKHZYGz`bmXczeoR*Z-Hs=yh7cWRx f0MJ?nL(>XNZ3Ars^Rf>h;}|?${an^LB{Ts5OHX0g diff --git a/doc/tutorial/images/toc-minus.png b/doc/tutorial/images/toc-minus.png deleted file mode 100644 index abbb020c8e2d6705ebc2f0fc17deed30f2977a46..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngf0VEhsJkjh1QcOwS?k)@rt9q4-G!sMP)HD-wQzH`-1CumMgJctv6pLi@6hos# qqtv?{|7HPo@q%;(0Ig*(G_A1IHqbUOFZ%#8j=|H_&t;ucLK6V~f=xvL diff --git a/doc/tutorial/images/toc-plus.png b/doc/tutorial/images/toc-plus.png deleted file mode 100644 index 941312ce0dab168e0efcc5b572e387259880e541..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngf0VEhsJkjh1QcOwS?k)@rt9q49T#T`K7w7|w?rspM=lmg95OfodLFfd9rOi4*hH8wIdOfpPPHA_l1 vPBO4aOiebg{FXd_r6qS{MX+1QdG|HK%AA z&M|bF#=*s&OJYO?ftdq@1MW_{{H_c7!85p5(1lc z&#VJx3C1LEcNc~ZR#^`qC(YBvF{I+w)Ct~v2NXD1b6>NwI=-vFd2Ozz_LBUAZ6_V# z0_-2ED|^IRKipvRGe~yg+2{$+0#aW-GMHneR${}Twfy{=Zu8*Wewig#Kj<-8yG4i7iAWgR668V7MElu>!lX!rIZ%r=auLs=jTq` zrMLrVoEF%)%=Em(l2V{~M&{;5#umm#78a?N$;qjPhKZ(zMyW=L7Ktfo#^y-|**sf- lni%*%x&naKG8mgy7@BGuXd4LCxqSjjdAj{!F!o39xr+d_Vw5fMTEwpb-s#9q<5Nzz6gIepyU?Lctpr{ZK zVzWaWPAC)#17S8h%;AIuf(Q_yeIybEqS0s^i1YdJcsv0ln9M{Xkpz;-I_^=P))~D~!!Hvpq{Dl8O{rN@cECkt>#DncX%I(O&3i_YgL-$m$VU zT3cLBLS%M1`o{TBX}S|Tbhc)vk!Yp)%rdDd&my(RPsxl%lU$)tC?(1~WuEwClUQn! n$Q8O{Mxt@ukkcT{K0> diff --git a/doc/tutorial/includeaddattribute.c b/doc/tutorial/includeaddattribute.c deleted file mode 100644 index bb6a18b47..000000000 --- a/doc/tutorial/includeaddattribute.c +++ /dev/null @@ -1,64 +0,0 @@ - -#include -#include -#include -#include - - -xmlDocPtr -parseDoc(char *docname, char *uri) { - - xmlDocPtr doc; - xmlNodePtr cur; - xmlNodePtr newnode; - xmlAttrPtr newattr; - - doc = xmlParseFile(docname); - - if (doc == NULL ) { - fprintf(stderr,"Document not parsed successfully. \n"); - return (NULL); - } - - cur = xmlDocGetRootElement(doc); - - if (cur == NULL) { - fprintf(stderr,"empty document\n"); - xmlFreeDoc(doc); - return (NULL); - } - - if (xmlStrcmp(cur->name, (const xmlChar *) "story")) { - fprintf(stderr,"document of the wrong type, root node != story"); - xmlFreeDoc(doc); - return (NULL); - } - - newnode = xmlNewTextChild (cur, NULL, "reference", NULL); - newattr = xmlNewProp (newnode, "uri", uri); - return(doc); -} - -int -main(int argc, char **argv) { - - char *docname; - char *uri; - xmlDocPtr doc; - - if (argc <= 2) { - printf("Usage: %s docname, uri\n", argv[0]); - return(0); - } - - docname = argv[1]; - uri = argv[2]; - doc = parseDoc (docname, uri); - if (doc != NULL) { - xmlSaveFormatFile (docname, doc, 1); - xmlFreeDoc(doc); - } - return (1); -} -]]> diff --git a/doc/tutorial/includeaddkeyword.c b/doc/tutorial/includeaddkeyword.c deleted file mode 100644 index 975168d70..000000000 --- a/doc/tutorial/includeaddkeyword.c +++ /dev/null @@ -1,75 +0,0 @@ - -#include -#include -#include -#include - -void -parseStory (xmlDocPtr doc, xmlNodePtr cur, char *keyword) { - - xmlNewTextChild (cur, NULL, "keyword", keyword); - return; -} - -xmlDocPtr -parseDoc(char *docname, char *keyword) { - - xmlDocPtr doc; - xmlNodePtr cur; - - doc = xmlParseFile(docname); - - if (doc == NULL ) { - fprintf(stderr,"Document not parsed successfully. \n"); - return (NULL); - } - - cur = xmlDocGetRootElement(doc); - - if (cur == NULL) { - fprintf(stderr,"empty document\n"); - xmlFreeDoc(doc); - return (NULL); - } - - if (xmlStrcmp(cur->name, (const xmlChar *) "story")) { - fprintf(stderr,"document of the wrong type, root node != story"); - xmlFreeDoc(doc); - return (NULL); - } - - cur = cur->xmlChildrenNode; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){ - parseStory (doc, cur, keyword); - } - - cur = cur->next; - } - return(doc); -} - -int -main(int argc, char **argv) { - - char *docname; - char *keyword; - xmlDocPtr doc; - - if (argc <= 2) { - printf("Usage: %s docname, keyword\n", argv[0]); - return(0); - } - - docname = argv[1]; - keyword = argv[2]; - doc = parseDoc (docname, keyword); - if (doc != NULL) { - xmlSaveFormatFile (docname, doc, 0); - xmlFreeDoc(doc); - } - - return (1); -} -]]> diff --git a/doc/tutorial/includeconvert.c b/doc/tutorial/includeconvert.c deleted file mode 100644 index 482e56fc0..000000000 --- a/doc/tutorial/includeconvert.c +++ /dev/null @@ -1,73 +0,0 @@ - -#include - - -unsigned char* -convert (unsigned char *in, char *encoding) -{ - unsigned char *out; - int ret,size,out_size,temp; - xmlCharEncodingHandlerPtr handler; - - size = (int)strlen(in)+1; - out_size = size*2-1; - out = malloc((size_t)out_size); - - if (out) { - handler = xmlFindCharEncodingHandler(encoding); - - if (!handler) { - free(out); - out = NULL; - } - } - if (out) { - temp=size-1; - ret = handler->input(out, &out_size, in, &temp); - if (ret || temp-size+1) { - if (ret) { - printf("conversion wasn't successful.\n"); - } else { - printf("conversion wasn't successful. converted: %i octets.\n",temp); - } - free(out); - out = NULL; - } else { - out = realloc(out,out_size+1); - out[out_size]=0; /*null terminating out*/ - - } - } else { - printf("no mem\n"); - } - return (out); -} - - -int -main(int argc, char **argv) { - - unsigned char *content, *out; - xmlDocPtr doc; - xmlNodePtr rootnode; - char *encoding = "ISO-8859-1"; - - - if (argc <= 1) { - printf("Usage: %s content\n", argv[0]); - return(0); - } - - content = argv[1]; - - out = convert(content, encoding); - - doc = xmlNewDoc ("1.0"); - rootnode = xmlNewDocNode(doc, NULL, (const xmlChar*)"root", out); - xmlDocSetRootElement(doc, rootnode); - - xmlSaveFormatFileEnc("-", doc, encoding, 1); - return (1); -} -]]> diff --git a/doc/tutorial/includegetattribute.c b/doc/tutorial/includegetattribute.c deleted file mode 100644 index b2b747110..000000000 --- a/doc/tutorial/includegetattribute.c +++ /dev/null @@ -1,72 +0,0 @@ - -#include -#include -#include -#include - -void -getReference (xmlDocPtr doc, xmlNodePtr cur) { - - xmlChar *uri; - cur = cur->xmlChildrenNode; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) { - uri = xmlGetProp(cur, "uri"); - printf("uri: %s\n", uri); - xmlFree(uri); - } - cur = cur->next; - } - return; -} - - -void -parseDoc(char *docname) { - - xmlDocPtr doc; - xmlNodePtr cur; - - doc = xmlParseFile(docname); - - if (doc == NULL ) { - fprintf(stderr,"Document not parsed successfully. \n"); - return; - } - - cur = xmlDocGetRootElement(doc); - - if (cur == NULL) { - fprintf(stderr,"empty document\n"); - xmlFreeDoc(doc); - return; - } - - if (xmlStrcmp(cur->name, (const xmlChar *) "story")) { - fprintf(stderr,"document of the wrong type, root node != story"); - xmlFreeDoc(doc); - return; - } - - getReference (doc, cur); - xmlFreeDoc(doc); - return; -} - -int -main(int argc, char **argv) { - - char *docname; - - if (argc <= 1) { - printf("Usage: %s docname\n", argv[0]); - return(0); - } - - docname = argv[1]; - parseDoc (docname); - - return (1); -} -]]> diff --git a/doc/tutorial/includekeyword.c b/doc/tutorial/includekeyword.c deleted file mode 100644 index e9bb46724..000000000 --- a/doc/tutorial/includekeyword.c +++ /dev/null @@ -1,79 +0,0 @@ - -#include -#include -#include -#include - -void -parseStory (xmlDocPtr doc, xmlNodePtr cur) { - - xmlChar *key; - cur = cur->xmlChildrenNode; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) { - key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); - printf("keyword: %s\n", key); - xmlFree(key); - } - cur = cur->next; - } - return; -} - -static void -parseDoc(char *docname) { - - xmlDocPtr doc; - xmlNodePtr cur; - - doc = xmlParseFile(docname); - - if (doc == NULL ) { - fprintf(stderr,"Document not parsed successfully. \n"); - return; - } - - cur = xmlDocGetRootElement(doc); - - if (cur == NULL) { - fprintf(stderr,"empty document\n"); - xmlFreeDoc(doc); - return; - } - - if (xmlStrcmp(cur->name, (const xmlChar *) "story")) { - fprintf(stderr,"document of the wrong type, root node != story"); - xmlFreeDoc(doc); - return; - } - - cur = cur->xmlChildrenNode; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){ - parseStory (doc, cur); - } - - cur = cur->next; - } - - xmlFreeDoc(doc); - return; -} - -int -main(int argc, char **argv) { - - char *docname; - - if (argc <= 1) { - printf("Usage: %s docname\n", argv[0]); - return(0); - } - - docname = argv[1]; - parseDoc (docname); - - return (1); -} -]]> diff --git a/doc/tutorial/includestory.xml b/doc/tutorial/includestory.xml deleted file mode 100644 index 2a22c899e..000000000 --- a/doc/tutorial/includestory.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - John Fleck - June 2, 2002 - example keyword - - - This is the headline - This is the body text. - - -]]> \ No newline at end of file diff --git a/doc/tutorial/includexpath.c b/doc/tutorial/includexpath.c deleted file mode 100644 index 6b66e6055..000000000 --- a/doc/tutorial/includexpath.c +++ /dev/null @@ -1,74 +0,0 @@ - -#include - -xmlDocPtr -getdoc (char *docname) { - xmlDocPtr doc; - doc = xmlParseFile(docname); - - if (doc == NULL ) { - fprintf(stderr,"Document not parsed successfully. \n"); - return NULL; - } - - return doc; -} - -xmlXPathObjectPtr -getnodeset (xmlDocPtr doc, xmlChar *xpath){ - - xmlXPathContextPtr context; - xmlXPathObjectPtr result; - - context = xmlXPathNewContext(doc); - if (context == NULL) { - printf("Error in xmlXPathNewContext\n"); - return NULL; - } - result = xmlXPathEvalExpression(xpath, context); - xmlXPathFreeContext(context); - if (result == NULL) { - printf("Error in xmlXPathEvalExpression\n"); - return NULL; - } - if(xmlXPathNodeSetIsEmpty(result->nodesetval)){ - xmlXPathFreeObject(result); - printf("No result\n"); - return NULL; - } - return result; -} -int -main(int argc, char **argv) { - - char *docname; - xmlDocPtr doc; - xmlChar *xpath = (xmlChar*) "//keyword"; - xmlNodeSetPtr nodeset; - xmlXPathObjectPtr result; - int i; - xmlChar *keyword; - - if (argc <= 1) { - printf("Usage: %s docname\n", argv[0]); - return(0); - } - - docname = argv[1]; - doc = getdoc(docname); - result = getnodeset (doc, xpath); - if (result) { - nodeset = result->nodesetval; - for (i=0; i < nodeset->nodeNr; i++) { - keyword = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); - printf("keyword: %s\n", keyword); - xmlFree(keyword); - } - xmlXPathFreeObject (result); - } - xmlFreeDoc(doc); - xmlCleanupParser(); - return (1); -} -]]> \ No newline at end of file diff --git a/doc/tutorial/index.html b/doc/tutorial/index.html deleted file mode 100644 index 8fb5897db..000000000 --- a/doc/tutorial/index.html +++ /dev/null @@ -1,14 +0,0 @@ -Libxml Tutorial

    Libxml Tutorial

    John Fleck

    Revision History
    Revision 1June 4, 2002
    Initial draft
    Revision 2June 12, 2002
    retrieving attribute value added
    Revision 3Aug. 31, 2002
    freeing memory fix
    Revision 4Nov. 10, 2002
    encoding discussion added
    Revision 5Dec. 15, 2002
    more memory freeing changes
    Revision 6Jan. 26. 2003
    add index
    Revision 7April 25, 2003
    add compilation appendix
    Revision 8July 24, 2003
    add XPath example
    Revision 9Feb. 14, 2004
    Fix bug in XPath example
    Revision 7Aug. 24, 2004
    Fix another bug in XPath example

    Abstract

    Libxml is a freely licensed C language library for handling - XML, portable across a large number of platforms. This - tutorial provides examples of its basic functions.

    Introduction

    Libxml is a C language library implementing functions for reading, - creating and manipulating XML data. This tutorial - provides example code and explanations of its basic functionality.

    Libxml and more details about its use are available on the project home page. Included there is complete - API documentation. This tutorial is not meant - to substitute for that complete documentation, but to illustrate the - functions needed to use the library to perform basic operations. - -

    The tutorial is based on a simple XML application I - use for articles I write. The format includes metadata and the body - of the article.

    The example code in this tutorial demonstrates how to: -

    • Parse the document.

    • Extract the text within a specified element.

    • Add an element and its content.

    • Add an attribute.

    • Extract the value of an attribute.

    -

    Full code for the examples is included in the appendices.

    diff --git a/doc/tutorial/ix01.html b/doc/tutorial/ix01.html deleted file mode 100644 index fca9d42f3..000000000 --- a/doc/tutorial/ix01.html +++ /dev/null @@ -1 +0,0 @@ -Index

    Index

    A

    attribute
    retrieving value, Retrieving Attributes
    writing, Writing Attribute

    C

    compiler flags, Compilation

    E

    element
    retrieving content, Retrieving Element Content
    writing content, Writing element content
    encoding, Parsing the file, Encoding Conversion

    X

    xmlChar, Data Types
    xmlDoc, Data Types
    xmlNodePtr, Data Types
    diff --git a/doc/tutorial/meson.build b/doc/tutorial/meson.build deleted file mode 100644 index 96349d2d4..000000000 --- a/doc/tutorial/meson.build +++ /dev/null @@ -1,82 +0,0 @@ - -tutorial_files = files( - 'apa.html', - 'apb.html', - 'apc.html', - 'apd.html', - 'ape.html', - 'apf.html', - 'apg.html', - 'aph.html', - 'api.html', - 'ar01s02.html', - 'ar01s03.html', - 'ar01s04.html', - 'ar01s05.html', - 'ar01s06.html', - 'ar01s07.html', - 'ar01s08.html', - 'ar01s09.html', - 'includeaddattribute.c', - 'includeaddkeyword.c', - 'includeconvert.c', - 'includegetattribute.c', - 'includekeyword.c', - 'includexpath.c', - 'index.html', - 'ix01.html', -) - -install_data(tutorial_files, install_dir: dir_doc / 'tutorial') - -tutorial_image_files = files( - 'images/blank.png', - 'images/caution.png', - 'images/draft.png', - 'images/home.png', - 'images/important.png', - 'images/next.png', - 'images/note.png', - 'images/prev.png', - 'images/tip.png', - 'images/toc-blank.png', - 'images/toc-minus.png', - 'images/toc-plus.png', - 'images/up.png', - 'images/warning.png', -) - -install_data(tutorial_image_files, install_dir: dir_doc / 'tutorial' / 'images') - -tutorial_image_files = files( - 'images/blank.png', - 'images/caution.png', - 'images/draft.png', - 'images/home.png', - 'images/important.png', - 'images/next.png', - 'images/note.png', - 'images/prev.png', - 'images/tip.png', - 'images/toc-blank.png', - 'images/toc-minus.png', - 'images/toc-plus.png', - 'images/up.png', - 'images/warning.png', -) - -install_data(tutorial_image_files, install_dir: dir_doc / 'tutorial' / 'images') -tutorial_image_files = files( - 'images/callouts/1.png', - 'images/callouts/10.png', - 'images/callouts/2.png', - 'images/callouts/3.png', - 'images/callouts/4.png', - 'images/callouts/5.png', - 'images/callouts/6.png', - 'images/callouts/7.png', - 'images/callouts/8.png', - 'images/callouts/9.png', -) - -install_data(tutorial_image_files, install_dir: dir_doc / 'tutorial' / 'images' / 'callouts') diff --git a/doc/tutorial/xmltutorial.xml b/doc/tutorial/xmltutorial.xml deleted file mode 100644 index 08bcd5be6..000000000 --- a/doc/tutorial/xmltutorial.xml +++ /dev/null @@ -1,747 +0,0 @@ - - - - - - - - -]> -
    - - Libxml Tutorial - - John - Fleck - jfleck@inkstain.net - - - 2002, 2003 - John Fleck - - - - 1 - June 4, 2002 - Initial draft - - - 2 - June 12, 2002 - retrieving attribute value added - - - 3 - Aug. 31, 2002 - freeing memory fix - - - 4 - Nov. 10, 2002 - encoding discussion added - - - 5 - Dec. 15, 2002 - more memory freeing changes - - - 6 - Jan. 26. 2003 - add index - - - 7 - April 25, 2003 - add compilation appendix - - - 8 - July 24, 2003 - add XPath example - - - 9 - Feb. 14, 2004 - Fix bug in XPath example - - - 7 - Aug. 24, 2004 - Fix another bug in XPath example - - - - - Libxml is a freely licensed C language library for handling - XML, portable across a large number of platforms. This - tutorial provides examples of its basic functions. - - - Introduction - Libxml is a C language library implementing functions for reading, - creating and manipulating XML data. This tutorial - provides example code and explanations of its basic functionality. - Libxml and more details about its use are available on the project home page. Included there is complete - API documentation. This tutorial is not meant - to substitute for that complete documentation, but to illustrate the - functions needed to use the library to perform basic operations. - - - The tutorial is based on a simple XML application I - use for articles I write. The format includes metadata and the body - of the article. - The example code in this tutorial demonstrates how to: - - - Parse the document. - - - Extract the text within a specified element. - - - Add an element and its content. - - - Add an attribute. - - - Extract the value of an attribute. - - - - Full code for the examples is included in the appendices. - - - - - Data Types - Libxml declares a number of data types we - will encounter repeatedly, hiding the messy stuff so you do not have to deal - with it unless you have some specific need. - - - - - xmlChar - -xmlChar - - A basic replacement for char, a byte in a UTF-8 encoded - string. If your data uses another encoding, it must be converted to - UTF-8 for use with libxml's - functions. More information on encoding is available on the libxml encoding support web page. - - - - - xmlDoc - - xmlDoc - - A structure containing the tree created by a parsed doc. xmlDocPtr - is a pointer to the structure. - - - - - xmlNodePtr - -xmlNodePtr - and xmlNode - - A structure containing a single node. xmlNodePtr - is a pointer to the structure, and is used in traversing the document tree. - - - - - - - - - Parsing the file - - file - parsing - -Parsing the file requires only the name of the file and a single - function call, plus error checking. Full code: - - - xmlDocPtr doc; - xmlNodePtr cur; - - doc = xmlParseFile(docname); - - if (doc == NULL ) { - fprintf(stderr,"Document not parsed successfully. \n"); - return; - } - - cur = xmlDocGetRootElement(doc); - - if (cur == NULL) { - fprintf(stderr,"empty document\n"); - xmlFreeDoc(doc); - return; - } - - if (xmlStrcmp(cur->name, (const xmlChar *) "story")) { - fprintf(stderr,"document of the wrong type, root node != story"); - xmlFreeDoc(doc); - return; - } - - - - - Declare the pointer that will point to your parsed document. - - - Declare a node pointer (you'll need this in order to - interact with individual nodes). - - - Check to see that the document was successfully parsed. If it - was not, libxml will at this point - register an error and stop. - - - encoding - -One common example of an error at this point is improper - handling of encoding. The XML standard requires - documents stored with an encoding other than UTF-8 or UTF-16 to - contain an explicit declaration of their encoding. If the - declaration is there, libxml will - automatically perform the necessary conversion to UTF-8 for - you. More information on XML's encoding - requirements is contained in the standard. - - - - - Retrieve the document's root element. - - - Check to make sure the document actually contains something. - - - In our case, we need to make sure the document is the right - type. "story" is the root type of the documents used in this - tutorial. - - - - - - - - Retrieving Element Content - - element - retrieving content - -Retrieving the content of an element involves traversing the document - tree until you find what you are looking for. In this case, we are looking - for an element called "keyword" contained within element called "story". The - process to find the node we are interested in involves tediously walking the - tree. We assume you already have an xmlDocPtr called doc - and an xmlNodPtr called cur. - - - - cur = cur->xmlChildrenNode; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){ - parseStory (doc, cur); - } - - cur = cur->next; - } - - - - - Get the first child node of cur. At this - point, cur points at the document root, which is - the element "story". - - - This loop iterates through the elements that are children of - "story", looking for one called "storyinfo". That - is the element that will contain the "keywords" we are - looking for. It uses the libxml string - comparison - function, xmlStrcmp. If there is a match, it calls the function parseStory. - - - - - - -void -parseStory (xmlDocPtr doc, xmlNodePtr cur) { - - xmlChar *key; - cur = cur->xmlChildrenNode; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) { - key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); - printf("keyword: %s\n", key); - xmlFree(key); - } - cur = cur->next; - } - return; -} - - - - Again we get the first child node. - - - Like the loop above, we then iterate through the nodes, looking - for one that matches the element we're interested in, in this case - "keyword". - - - When we find the "keyword" element, we need to print - its contents. Remember that in XML, the text - contained within an element is a child node of that element, so we - turn to cur->xmlChildrenNode. To retrieve it, we - use the function xmlNodeListGetString, which also takes the doc pointer as an argument. In this case, we just print it out. - - Because xmlNodeListGetString allocates - memory for the string it returns, you must use - xmlFree to free it. - - - - - - - - Using XPath to Retrieve Element Content - In addition to walking the document tree to find an element, - Libxml2 includes support for - use of XPath expressions to retrieve sets of - nodes that match a specified criteria. Full documentation of the - XPath API is here. - - XPath allows searching through a document - for nodes that match specified criteria. In the example below we search - through a document for the contents of all keyword - elements. - - A full discussion of XPath is beyond - the scope of this document. For details on its use, see the XPath specification. - - Full code for this example is at . - - Using XPath requires setting up an - xmlXPathContext and then supplying the XPath - expression and the context to the - xmlXPathEvalExpression function. The function returns - an xmlXPathObjectPtr, which includes the set of nodes satisfying the - XPath expression. - - - xmlXPathObjectPtr - getnodeset (xmlDocPtr doc, xmlChar *xpath){ - - xmlXPathContextPtr context; - xmlXPathObjectPtr result; - - context = xmlXPathNewContext(doc); - result = xmlXPathEvalExpression(xpath, context); - if(xmlXPathNodeSetIsEmpty(result->nodesetval)){ - xmlXPathFreeObject(result); - printf("No result\n"); - return NULL; - - - - First we declare our variables. - - - Initialize the context variable. - - - Apply the XPath expression. - - - Check the result and free the memory allocated to - result if no result is found. - - - - The xmlPathObjectPtr returned by the function contains a set of nodes - and other information needed to iterate through the set and act on the - results. For this example, our functions returns the - xmlXPathObjectPtr. We use it to print the contents of - keyword nodes in our document. The node set object - includes the number of elements in the set (nodeNr) and - an array of nodes (nodeTab): - - for (i=0; i < nodeset->nodeNr; i++) { - keyword = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); - printf("keyword: %s\n", keyword); - xmlFree(keyword); - } - - - - The value of nodeset->Nr holds the number of - elements in the node set. Here we use it to iterate through the array. - - - Here we print the contents of each of the nodes returned. - - Note that we are printing the child node of the node that is - returned, because the contents of the keyword - element are a child text node. - - - - - - - - Writing element content - - element - writing content - - Writing element content uses many of the same steps we used above - — parsing the document and walking the tree. We parse the document, - then traverse the tree to find the place we want to insert our element. For - this example, we want to again find the "storyinfo" element and - this time insert a keyword. Then we'll write the file to disk. Full code: - - - The main difference in this example is in - parseStory: - - -void -parseStory (xmlDocPtr doc, xmlNodePtr cur, char *keyword) { - - xmlNewTextChild (cur, NULL, "keyword", keyword); - return; -} - - - - The xmlNewTextChild - function adds a new child element at the - current node pointer's location in the - tree, specified by cur. - - - - - - - file - saving - - Once the node has been added, we would like to write the document to - file. Is you want the element to have a namespace, you can add it here as - well. In our case, the namespace is NULL. - - xmlSaveFormatFile (docname, doc, 1); - - The first parameter is the name of the file to be written. You'll notice - it is the same as the file we just read. In this case, we just write over - the old file. The second parameter is a pointer to the xmlDoc - structure. Setting the third parameter equal to one ensures indenting on output. - - - - - Writing Attribute - - attribute - writing - -Writing an attribute is similar to writing text to a new element. In - this case, we'll add a reference URI to our - document. Full code:. - - A reference is a child of the story - element, so finding the place to put our new element and attribute is - simple. As soon as we do the error-checking test in our - parseDoc, we are in the right spot to add our - element. But before we do that, we need to make a declaration using a - data type we have not seen yet: - - xmlAttrPtr newattr; - - We also need an extra xmlNodePtr: - - xmlNodePtr newnode; - - - - The rest of parseDoc is the same as before until we - check to see if our root element is story. If it is, - then we know we are at the right spot to add our element: - - - newnode = xmlNewTextChild (cur, NULL, "reference", NULL); - newattr = xmlNewProp (newnode, "uri", uri); - - - - First we add a new node at the location of the current node - pointer, cur. using the xmlNewTextChild function. - - - - - Once the node is added, the file is written to disk just as in the - previous example in which we added an element with text content. - - - - - Retrieving Attributes - - attribute - retrieving value - -Retrieving the value of an attribute is similar to the previous - example in which we retrieved a node's text contents. In this case we'll - extract the value of the URI we added in the previous - section. Full code: . - - The initial steps for this example are similar to the previous ones: parse - the doc, find the element you are interested in, then enter a function to - carry out the specific task required. In this case, we call - getReference: - -void -getReference (xmlDocPtr doc, xmlNodePtr cur) { - - xmlChar *uri; - cur = cur->xmlChildrenNode; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) { - uri = xmlGetProp(cur, "uri"); - printf("uri: %s\n", uri); - xmlFree(uri); - } - cur = cur->next; - } - return; -} - - - - - - The key function is xmlGetProp, which returns an - xmlChar containing the attribute's value. In this case, - we just print it out. - - - If you are using a DTD that declares a fixed or - default value for the attribute, this function will retrieve it. - - - - - - - - - - - Encoding Conversion - - - encoding - -Data encoding compatibility problems are one of the most common - difficulties encountered by programmers new to XML in - general and libxml in particular. Thinking - through the design of your application in light of this issue will help - avoid difficulties later. Internally, libxml - stores and manipulates data in the UTF-8 format. Data used by your program - in other formats, such as the commonly used ISO-8859-1 encoding, must be - converted to UTF-8 before passing it to libxml - functions. If you want your program's output in an encoding other than - UTF-8, you also must convert it. - - Libxml uses - iconv if it is available to convert - data. Without iconv, only UTF-8, UTF-16 and - ISO-8859-1 can be used as external formats. With - iconv, any format can be used provided - iconv is able to convert it to and from - UTF-8. Currently iconv supports about 150 - different character formats with ability to convert from any to any. While - the actual number of supported formats varies between implementations, every - iconv implementation is almost guaranteed to - support every format anyone has ever heard of. - - - A common mistake is to use different formats for the internal data - in different parts of one's code. The most common case is an application - that assumes ISO-8859-1 to be the internal data format, combined with - libxml, which assumes UTF-8 to be the - internal data format. The result is an application that treats internal - data differently, depending on which code section is executing. The one or - the other part of code will then, naturally, misinterpret the data. - - - - This example constructs a simple document, then adds content provided - at the command line to the document's root element and outputs the results - to stdout in the proper encoding. For this example, we - use ISO-8859-1 encoding. The encoding of the string input at the command - line is converted from ISO-8859-1 to UTF-8. Full code: - - The conversion, encapsulated in the example code in the - convert function, uses - libxml's - xmlFindCharEncodingHandler function: - - xmlCharEncodingHandlerPtr handler; - size = (int)strlen(in)+1; - out_size = size*2-1; - out = malloc((size_t)out_size); - -… - handler = xmlFindCharEncodingHandler(encoding); -… - handler->input(out, &out_size, in, &temp); -… - xmlSaveFormatFileEnc("-", doc, encoding, 1); - - - - handler is declared as a pointer to an - xmlCharEncodingHandler function. - - - The xmlCharEncodingHandler function needs - to be given the size of the input and output strings, which are - calculated here for strings in and - out. - - - xmlFindCharEncodingHandler takes as its - argument the data's initial encoding and searches - libxml's built-in set of conversion - handlers, returning a pointer to the function or NULL if none is - found. - - - The conversion function identified by handler - requires as its arguments pointers to the input and output strings, - along with the length of each. The lengths must be determined - separately by the application. - - - To output in a specified encoding rather than UTF-8, we use - xmlSaveFormatFileEnc, specifying the - encoding. - - - - - - - Compilation - - compiler flags - - Libxml includes a script, - xml2-config, that can be used to generate - flags for compilation and linking of programs written with the - library. For pre-processor and compiler flags, use xml2-config - --cflags. For library linking flags, use xml2-config - --libs. Other options are available using xml2-config - --help. - - - - Sample Document - &STORY; - - - Code for Keyword Example - - &KEYWORD; - - - - Code for XPath Example - - &XPATH; - - - - Code for Add Keyword Example - - &ADDKEYWORD; - - - - Code for Add Attribute Example - - &ADDATTRIBUTE; - - - - Code for Retrieving Attribute Value Example - - &GETATTRIBUTE; - - - - Code for Encoding Conversion Example - - &CONVERT; - - - - Acknowledgements - A number of people have generously offered feedback, code and - suggested improvements to this tutorial. In no particular order: - - Daniel Veillard - Marcus Labib Iskander - Christopher R. Harris - Igor Zlatkovic - Niraj Tolia - David Turover - - - - -
    From bffef46c4c3cb832f9a1b9f5c2334202baf6effd Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 28 Apr 2024 22:58:06 +0200 Subject: [PATCH 418/504] doc: Don't install example code --- Makefile.am | 6 ------ meson.build | 2 -- python/tests/Makefile.am | 7 ++----- python/tests/meson.build | 5 ----- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/Makefile.am b/Makefile.am index 727185e43..9eff073e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -396,12 +396,6 @@ pkgconfig_DATA = libxml-2.0.pc cmakedir = $(libdir)/cmake/libxml2 cmake_DATA = libxml2-config.cmake -# -# Install the tests program sources as examples -# -examplesdir = $(docdir)/examples -examples_DATA = xmllint.c - tst: tst.c $(CC) $(CFLAGS) -Iinclude -o tst tst.c .libs/libxml2.a -lpthread -lm -lz -llzma diff --git a/meson.build b/meson.build index 582badf48..450d80bb7 100644 --- a/meson.build +++ b/meson.build @@ -814,8 +814,6 @@ configure_file( install_data(files('libxml.m4'), install_dir: dir_data / 'aclocal') -install_data(files('xmllint.c'), install_dir: dir_doc / 'examples') - if support_tls == false message('===============================================================') message('WARNING: Your C compiler appears to not support thread-local') diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am index e30058e32..0f6caddf9 100644 --- a/python/tests/Makefile.am +++ b/python/tests/Makefile.am @@ -1,6 +1,3 @@ -exampledir = $(docdir)/python/examples -dist_example_DATA = $(PYTESTS) $(XMLS) setup_test.py - PYTESTS= \ build.py \ attribs.py \ @@ -56,6 +53,8 @@ XMLS= \ invalid.xml \ test.dtd +EXTRA_DIST = $(PYTESTS) $(XMLS) setup_test.py meson.build + CLEANFILES = core tmp.xml *.pyc if WITH_PYTHON @@ -75,5 +74,3 @@ check-local: fi ; \ done) endif - -EXTRA_DIST = meson.build diff --git a/python/tests/meson.build b/python/tests/meson.build index 9027c45b0..1c56fddce 100644 --- a/python/tests/meson.build +++ b/python/tests/meson.build @@ -56,8 +56,3 @@ xml_files = files( 'tst.xml', 'valid.xml', ) - -install_data( - [python_test_files, xml_files, files('setup_test.py')], - install_dir: dir_doc / 'python' / 'examples', -) From ae960cac9664328200aa37866cfa1d5e8c3bb1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20=C5=BDen=C4=8D=C3=A1k?= Date: Tue, 7 Nov 2023 21:08:01 +0100 Subject: [PATCH 419/504] Allow unlimited length decimals, integers etc. --- runsuite.c | 11 +- xmlschemastypes.c | 943 ++++++++++++++++++++-------------------------- 2 files changed, 405 insertions(+), 549 deletions(-) diff --git a/runsuite.c b/runsuite.c index a36a5f3d3..75b8f3ad7 100644 --- a/runsuite.c +++ b/runsuite.c @@ -1026,7 +1026,7 @@ xstcMetadata(const char *metadata, const char *base) { int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { int ret = 0; - int old_errors, old_tests, old_leaks; + int old_errors, old_tests, old_leaks, expected_errors; logfile = fopen(LOGFILE, "w"); if (logfile == NULL) { @@ -1044,16 +1044,17 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { old_tests = nb_tests; old_leaks = nb_leaks; xsdTest(); + expected_errors = 3; printf("Ran %d tests, %d errors, %d leaks\n", nb_tests - old_tests, nb_errors - old_errors, nb_leaks - old_leaks); - if (nb_errors - old_errors == 10) { - printf("10 errors were expected\n"); + if (nb_errors - old_errors == expected_errors) { + printf("%d errors were expected\n", expected_errors); nb_errors = old_errors; } else { - printf("10 errors were expected, got %d errors\n", - nb_errors - old_errors); + printf("%d errors were expected, got %d errors\n", + expected_errors, nb_errors - old_errors); nb_errors = old_errors + 1; } diff --git a/xmlschemastypes.c b/xmlschemastypes.c index 60f3d37fb..5c6db2927 100644 --- a/xmlschemastypes.c +++ b/xmlschemastypes.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -77,15 +78,11 @@ struct _xmlSchemaValDuration { typedef struct _xmlSchemaValDecimal xmlSchemaValDecimal; typedef xmlSchemaValDecimal *xmlSchemaValDecimalPtr; -struct _xmlSchemaValDecimal { - /* would use long long but not portable */ - unsigned long lo; - unsigned long mi; - unsigned long hi; - unsigned int extra; - unsigned int sign:1; - unsigned int frac:7; - unsigned int total:8; +struct _xmlSchemaValDecimal +{ + xmlChar *str; + unsigned integralPlaces; + unsigned fractionalPlaces; }; typedef struct _xmlSchemaValQName xmlSchemaValQName; @@ -231,6 +228,8 @@ static xmlSchemaFacetPtr xmlSchemaNewMinLengthFacet(int value) { xmlSchemaFacetPtr ret; + size_t bufsize; + xmlSchemaValDecimal *decimal; ret = xmlSchemaNewFacet(); if (ret == NULL) { @@ -240,9 +239,19 @@ xmlSchemaNewMinLengthFacet(int value) ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER); if (ret->val == NULL) { xmlFree(ret); - return(NULL); + return(NULL); } - ret->val->value.decimal.lo = value; + bufsize = snprintf(NULL, 0, "%+d.0", value) + 1; + decimal = &ret->val->value.decimal; + decimal->str = xmlMalloc(bufsize); + if (decimal->str == NULL) + { + xmlSchemaFreeFacet(ret); + return NULL; + } + snprintf((char *)decimal->str, bufsize, "%+d.0", value); + decimal->integralPlaces = bufsize - 4; + decimal->fractionalPlaces = 1; return (ret); } @@ -321,6 +330,90 @@ xmlSchemaInitBasicType(const char *name, xmlSchemaValType type, return(ret); } +static const xmlChar * +xmlSchemaValDecimalGetFractionalPart(const xmlSchemaValDecimal *decimal) +{ + /* 2 = sign+dot */ + return decimal->str+2+decimal->integralPlaces; +} + +static int +xmlSchemaValDecimalIsInteger(const xmlSchemaValDecimal *decimal) +{ + return decimal->fractionalPlaces == 1 && xmlSchemaValDecimalGetFractionalPart(decimal)[0] == '0'; +} + +static unsigned long +xmlSchemaValDecimalGetSignificantDigitCount(const xmlSchemaValDecimal *decimal) +{ + unsigned fractionalPlaces = xmlSchemaValDecimalIsInteger(decimal) ? 0 : decimal->fractionalPlaces; + unsigned integralPlaces = decimal->integralPlaces; + if(integralPlaces == 1 && decimal->str[1] == '0') + { + integralPlaces = 0; + } + if(integralPlaces+fractionalPlaces == 0) + { + /* 0, but that's still 1 significant digit */ + return 1; + } + return integralPlaces+fractionalPlaces; +} + +/** + * @brief Compares two decimals + * + * @param lhs + * @param rhs + * @return positive value if lhs > rhs, negative if lhs < rhs, or 0 if lhs == rhs + */ +static int xmlSchemaValDecimalCompare(const xmlSchemaValDecimal *lhs, const xmlSchemaValDecimal *rhs) +{ + int sign = 1; + /* may be +0 and -0 for some reason, handle */ + if(strcmp((const char*)lhs->str+1, "0.0") == 0 && + strcmp((const char*)rhs->str+1, "0.0") == 0) + { + return 0; + } + /* first take care of sign */ + if(lhs->str[0] != rhs->str[0]) + { + /* ASCII- > ASCII+ */ + return rhs->str[0]-lhs->str[0]; + } + /* signs are equal, but if negative the comparison must be reversed */ + if(lhs->str[0] == '-') + { + sign = -1; + } + /* internal representation never contains leading zeroes, longer decimal representation = larger number */ + if(lhs->integralPlaces != rhs->integralPlaces) + { + return ((int)lhs->integralPlaces-(int)rhs->integralPlaces)*sign; + } + /* same length, only digits => lexicographical sorting == numerical sorting. + If integral parts are equal it will compare compare fractional parts. Again, lexicographical is good enough, + length doesn't matter. We'll be starting from 0.1, always comparing like to like, and NULL < '0' + If one is shorter and is equal until end, it must be smaller, since there are no trailing zeroes + and the longer number must therefore have at least one non-zero digit after the other has ended. + +1 to skip the sign + */ + return strcmp((const char*)lhs->str+1, (const char*)rhs->str+1)*sign; +} + +static int xmlSchemaValDecimalCompareWithInteger(const xmlSchemaValDecimal *lhs, long rhs) +{ + /* can handle integers up to 128 bits, should be good for a while */ + char buf[43]; + xmlSchemaValDecimal tmpVal; + /* 3 = sign+dot+0+NULL */ + tmpVal.integralPlaces = snprintf(buf, sizeof(buf), "%+ld.0", rhs)-3; + tmpVal.str = (xmlChar*)buf; + tmpVal.fractionalPlaces = 1; + return xmlSchemaValDecimalCompare(lhs, &tmpVal); +} + /* * WARNING: Those type reside normally in xmlschemas.c but are * redefined here locally in oder of being able to use them for xs:anyType- @@ -1173,6 +1266,23 @@ xmlSchemaFreeValue(xmlSchemaValPtr value) { if (value->value.base64.str != NULL) xmlFree(value->value.base64.str); break; + case XML_SCHEMAS_DECIMAL: + case XML_SCHEMAS_INTEGER: + case XML_SCHEMAS_NNINTEGER: + case XML_SCHEMAS_PINTEGER: + case XML_SCHEMAS_NPINTEGER: + case XML_SCHEMAS_NINTEGER: + case XML_SCHEMAS_INT: + case XML_SCHEMAS_UINT: + case XML_SCHEMAS_LONG: + case XML_SCHEMAS_ULONG: + case XML_SCHEMAS_SHORT: + case XML_SCHEMAS_USHORT: + case XML_SCHEMAS_BYTE: + case XML_SCHEMAS_UBYTE: + if (value->value.decimal.str != NULL) + xmlFree(value->value.decimal.str); + break; default: break; } @@ -2232,21 +2342,16 @@ xmlSchemaValAtomicListNode(xmlSchemaTypePtr type, const xmlChar *value, /** * xmlSchemaParseUInt: * @str: pointer to the string R/W - * @llo: pointer to the low result - * @lmi: pointer to the mid result - * @lhi: pointer to the high result + * @val: pointer to the resulting decimal * - * Parse an unsigned long into 3 fields. + * Parse an unsigned long into a decimal. * * Returns the number of significant digits in the number or * -1 if overflow of the capacity and -2 if it's not a number. */ -static int -xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo, - unsigned long *lmi, unsigned long *lhi) { - unsigned long lo = 0, mi = 0, hi = 0; - const xmlChar *tmp, *cur = *str; - int ret = 0, i = 0; +static int xmlSchemaParseUInt(const xmlChar **str, xmlSchemaValDecimalPtr val) { + const xmlChar *tmp, *cur = *str; + int ret = 0, i = 0; if (!((*cur >= '0') && (*cur <= '9'))) return(-2); @@ -2254,31 +2359,29 @@ xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo, while (*cur == '0') { /* ignore leading zeroes */ cur++; } + /* back up in case there is nothing after the leading zeroes */ + if(!(*cur >= '0' && *cur <= '9')) + { + --cur; + } tmp = cur; while ((*tmp != 0) && (*tmp >= '0') && (*tmp <= '9')) { i++;tmp++;ret++; } - if (i > 24) { - *str = tmp; - return(-1); - } - while (i > 16) { - hi = hi * 10 + (*cur++ - '0'); - i--; - } - while (i > 8) { - mi = mi * 10 + (*cur++ - '0'); - i--; - } - while (i > 0) { - lo = lo * 10 + (*cur++ - '0'); - i--; + if (val->integralPlaces + val->fractionalPlaces < (unsigned)i + 1) + { + if (val->str != NULL) + { + xmlFree(val->str); + } + /* sign, dot, fractional 0 and NULL terminator */ + val->str = xmlMalloc(i + 4); } + val->fractionalPlaces = 1; + val->integralPlaces = i; + snprintf((char *)val->str, i + 4, "+%.*s.0", i, cur); - *str = cur; - *llo = lo; - *lmi = mi; - *lhi = hi; + *str = tmp; return(ret); } @@ -2466,9 +2569,11 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value, } case XML_SCHEMAS_DECIMAL:{ const xmlChar *cur = value; - unsigned int len, neg, integ, hasLeadingZeroes; - xmlChar cval[25]; - xmlChar *cptr = cval; + const xmlChar *numStart, *numEnd; + xmlSchemaValDecimal decimal; + xmlChar sign; + + memset(&decimal, 0, sizeof(decimal)); if ((cur == NULL) || (*cur == 0)) goto return1; @@ -2482,9 +2587,9 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value, /* * First we handle an optional sign. */ - neg = 0; + sign = '+'; if (*cur == '-') { - neg = 1; + sign = '-'; cur++; } else if (*cur == '+') cur++; @@ -2493,47 +2598,44 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value, */ if (*cur == 0) goto return1; - /* - * Next we "pre-parse" the number, in preparation for calling - * the common routine xmlSchemaParseUInt. We get rid of any - * leading zeroes (because we have reserved only 25 chars), - * and note the position of a decimal point. - */ - len = 0; - integ = ~0u; - hasLeadingZeroes = 0; + /* * Skip leading zeroes. */ while (*cur == '0') { cur++; - hasLeadingZeroes = 1; - } - if (*cur != 0) { - do { - if ((*cur >= '0') && (*cur <= '9')) { - *cptr++ = *cur++; - len++; - } else if (*cur == '.') { - cur++; - integ = len; - do { - if ((*cur >= '0') && (*cur <= '9')) { - *cptr++ = *cur++; - len++; - } else - break; - } while (len < 24); - /* - * Disallow "." but allow "00." - */ - if ((len == 0) && (!hasLeadingZeroes)) - goto return1; - break; - } else - break; - } while (len < 24); } + + numStart = cur; + + while ((*cur >= '0') && (*cur <= '9')) { + ++cur; + ++decimal.integralPlaces; + } + if (*cur == '.') { + ++cur; + } + while ((*cur >= '0') && (*cur <= '9')) { + ++cur; + ++decimal.fractionalPlaces; + } + + /* disallow "." */ + if ( + decimal.fractionalPlaces == 0 && decimal.integralPlaces == 0 + && (numStart == value || numStart[-1] != '0') + ) { + goto return1; + } + + numEnd = cur; + + /* find if there are trailing FRACTIONAL zeroes, and deal with them if necessary */ + while (numEnd > numStart && decimal.fractionalPlaces && numEnd[-1] == '0') { + --numEnd; + --decimal.fractionalPlaces; + } + if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur != 0) @@ -2541,50 +2643,36 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value, if (val != NULL) { v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL); if (v != NULL) { - /* - * Now evaluate the significant digits of the number - */ - if (len != 0) { - - if (integ != ~0u) { - /* - * Get rid of trailing zeroes in the - * fractional part. - */ - while ((len != integ) && (*(cptr-1) == '0')) { - cptr--; - len--; - } - } - /* - * Terminate the (preparsed) string. - */ - if (len != 0) { - *cptr = 0; - cptr = cval; - - xmlSchemaParseUInt((const xmlChar **)&cptr, - &v->value.decimal.lo, - &v->value.decimal.mi, - &v->value.decimal.hi); - } - } - /* - * Set the total digits to 1 if a zero value. - */ - v->value.decimal.sign = neg; - if (len == 0) { - /* Speedup for zero values. */ - v->value.decimal.total = 1; - } else { - v->value.decimal.total = len; - if (integ == ~0u) - v->value.decimal.frac = 0; - else - v->value.decimal.frac = len - integ; - } + /* create a standardized representation */ + size_t bufsize; + const char *integralStart = (const char *)numStart; + const char *fractionalStart = (const char *)numEnd - decimal.fractionalPlaces; + if (decimal.integralPlaces == 0) + { + integralStart = "0"; + decimal.integralPlaces = 1; + } + if (decimal.fractionalPlaces == 0) + { + fractionalStart = "0"; + decimal.fractionalPlaces = 1; + } + /* 3 = sign, dot, NULL terminator */ + bufsize = decimal.integralPlaces + decimal.fractionalPlaces + 3; + decimal.str = xmlMalloc(bufsize); + if (!decimal.str) + { + goto error; + } + snprintf((char *)decimal.str, bufsize, "%c%.*s.%.*s", sign, decimal.integralPlaces, integralStart, + decimal.fractionalPlaces, fractionalStart); + v->value.decimal = decimal; *val = v; } + else + { + goto error; + } } goto return0; } @@ -3339,199 +3427,152 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value, case XML_SCHEMAS_PINTEGER: case XML_SCHEMAS_NPINTEGER: case XML_SCHEMAS_NINTEGER: - case XML_SCHEMAS_NNINTEGER:{ - const xmlChar *cur = value; - unsigned long lo, mi, hi; - int sign = 0; - - if (cur == NULL) - goto return1; - if (normOnTheFly) - while IS_WSP_BLANK_CH(*cur) cur++; - if (*cur == '-') { - sign = 1; - cur++; - } else if (*cur == '+') - cur++; - ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi); - if (ret < 0) - goto return1; - if (normOnTheFly) - while IS_WSP_BLANK_CH(*cur) cur++; - if (*cur != 0) - goto return1; - if (type->builtInType == XML_SCHEMAS_NPINTEGER) { - if ((sign == 0) && - ((hi != 0) || (mi != 0) || (lo != 0))) - goto return1; - } else if (type->builtInType == XML_SCHEMAS_PINTEGER) { - if (sign == 1) - goto return1; - if ((hi == 0) && (mi == 0) && (lo == 0)) - goto return1; - } else if (type->builtInType == XML_SCHEMAS_NINTEGER) { - if (sign == 0) - goto return1; - if ((hi == 0) && (mi == 0) && (lo == 0)) - goto return1; - } else if (type->builtInType == XML_SCHEMAS_NNINTEGER) { - if ((sign == 1) && - ((hi != 0) || (mi != 0) || (lo != 0))) - goto return1; - } - if (val != NULL) { - v = xmlSchemaNewValue(type->builtInType); - if (v != NULL) { - if (ret == 0) - ret++; - v->value.decimal.lo = lo; - v->value.decimal.mi = mi; - v->value.decimal.hi = hi; - v->value.decimal.sign = sign; - v->value.decimal.frac = 0; - v->value.decimal.total = ret; - *val = v; - } - } - goto return0; - } + case XML_SCHEMAS_NNINTEGER: case XML_SCHEMAS_LONG: case XML_SCHEMAS_BYTE: case XML_SCHEMAS_SHORT: - case XML_SCHEMAS_INT:{ + case XML_SCHEMAS_INT: + case XML_SCHEMAS_UINT: + case XML_SCHEMAS_ULONG: + case XML_SCHEMAS_USHORT: + case XML_SCHEMAS_UBYTE: { const xmlChar *cur = value; - unsigned long lo, mi, hi; - int sign = 0; + xmlSchemaValDecimal decimal; + xmlChar sign = '+'; + + memset(&decimal, 0, sizeof(decimal)); if (cur == NULL) goto return1; - if (normOnTheFly) + if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur == '-') { - sign = 1; + sign = '-'; cur++; } else if (*cur == '+') cur++; - ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi); + ret = xmlSchemaParseUInt(&cur, &decimal); + /* add sign */ if (ret < 0) - goto return1; + goto valIntegerReturn1; + decimal.str[0] = sign; if (normOnTheFly) while IS_WSP_BLANK_CH(*cur) cur++; if (*cur != 0) - goto return1; - if (type->builtInType == XML_SCHEMAS_LONG) { - if (hi >= 922) { - if (hi > 922) - goto return1; - if (mi >= 33720368) { - if (mi > 33720368) - goto return1; - if ((sign == 0) && (lo > 54775807)) - goto return1; - if ((sign == 1) && (lo > 54775808)) - goto return1; - } - } - } else if (type->builtInType == XML_SCHEMAS_INT) { - if (hi != 0) - goto return1; - if (mi >= 21) { - if (mi > 21) - goto return1; - if ((sign == 0) && (lo > 47483647)) - goto return1; - if ((sign == 1) && (lo > 47483648)) - goto return1; - } - } else if (type->builtInType == XML_SCHEMAS_SHORT) { - if ((mi != 0) || (hi != 0)) - goto return1; - if ((sign == 1) && (lo > 32768)) - goto return1; - if ((sign == 0) && (lo > 32767)) - goto return1; - } else if (type->builtInType == XML_SCHEMAS_BYTE) { - if ((mi != 0) || (hi != 0)) - goto return1; - if ((sign == 1) && (lo > 128)) - goto return1; - if ((sign == 0) && (lo > 127)) - goto return1; + goto valIntegerReturn1; + if (type->builtInType == XML_SCHEMAS_NPINTEGER) + { + if(xmlSchemaValDecimalCompareWithInteger(&decimal, 0) > 0) + goto valIntegerReturn1; } - if (val != NULL) { - v = xmlSchemaNewValue(type->builtInType); - if (v != NULL) { - v->value.decimal.lo = lo; - v->value.decimal.mi = mi; - v->value.decimal.hi = hi; - v->value.decimal.sign = sign; - v->value.decimal.frac = 0; - v->value.decimal.total = ret; - *val = v; - } + else if (type->builtInType == XML_SCHEMAS_PINTEGER) + { + if (sign == '-') + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0) <= 0) + goto valIntegerReturn1; } - goto return0; - } - case XML_SCHEMAS_UINT: - case XML_SCHEMAS_ULONG: - case XML_SCHEMAS_USHORT: - case XML_SCHEMAS_UBYTE:{ - const xmlChar *cur = value; - unsigned long lo, mi, hi; - - if (normOnTheFly) - while IS_WSP_BLANK_CH(*cur) cur++; - ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi); - if (ret < 0) - goto return1; - if (normOnTheFly) - while IS_WSP_BLANK_CH(*cur) cur++; - if (*cur != 0) - goto return1; - if (type->builtInType == XML_SCHEMAS_ULONG) { - if (hi >= 1844) { - if (hi > 1844) - goto return1; - if (mi >= 67440737) { - if (mi > 67440737) - goto return1; - if (lo > 9551615) - goto return1; - } - } - } else if (type->builtInType == XML_SCHEMAS_UINT) { - if (hi != 0) - goto return1; - if (mi >= 42) { - if (mi > 42) - goto return1; - if (lo > 94967295) - goto return1; - } - } else if (type->builtInType == XML_SCHEMAS_USHORT) { - if ((mi != 0) || (hi != 0)) - goto return1; - if (lo > 65535) - goto return1; - } else if (type->builtInType == XML_SCHEMAS_UBYTE) { - if ((mi != 0) || (hi != 0)) - goto return1; - if (lo > 255) - goto return1; + else if (type->builtInType == XML_SCHEMAS_NINTEGER) + { + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0) >= 0) + goto valIntegerReturn1; + } + else if (type->builtInType == XML_SCHEMAS_NNINTEGER) + { + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0) < 0) + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_LONG) + { + /* (u)int64_t may not be available on 32 bit platform, just use decimal */ + xmlSchemaValDecimal tmpDecimal; + static const char maxLong[] = "+9223372036854775807.0"; + static const char minLong[] = "-9223372036854775808.0"; + tmpDecimal.fractionalPlaces = 1; + tmpDecimal.integralPlaces = 19; + tmpDecimal.str = BAD_CAST maxLong; + if (xmlSchemaValDecimalCompare(&decimal, &tmpDecimal) > 0) + goto valIntegerReturn1; + tmpDecimal.str = BAD_CAST minLong; + if (xmlSchemaValDecimalCompare(&decimal, &tmpDecimal) < 0) + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_ULONG) + { + xmlSchemaValDecimal tmpDecimal; + static const char maxULong[] = "+18446744073709551615.0"; + tmpDecimal.fractionalPlaces = 1; + tmpDecimal.integralPlaces = 20; + tmpDecimal.str = (xmlChar*)maxULong; + if (xmlSchemaValDecimalCompare(&decimal, &tmpDecimal) > 0) + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0) < 0) + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_INT) + { + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0x7fffffff) > 0) /* INT32_MAX */ + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, -0x7fffffff-1) < 0) /* INT32_MIN */ + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_SHORT) + { + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0x7fff) > 0) /* INT16_MAX */ + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, -0x8000) < 0) /* INT16_MIN */ + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_BYTE) + {if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0x7f) > 0) /* INT8_MAX */ + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, -0x80) < 0) /* INT8_MIN */ + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_UINT) + { + xmlSchemaValDecimal tmpDecimal; + static const char maxUInt[] = "+4294967295.0"; + tmpDecimal.fractionalPlaces = 1; + tmpDecimal.integralPlaces = 10; + tmpDecimal.str = (xmlChar*)maxUInt; + if (xmlSchemaValDecimalCompare(&decimal, &tmpDecimal) > 0) + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0) < 0) + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_USHORT) + { + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0xffff) > 0) /* UINT16_MAX */ + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0) < 0) + goto valIntegerReturn1; + } + else if(type->builtInType == XML_SCHEMAS_UBYTE) + { + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0xff) > 0) /* UINT8_MAX */ + goto valIntegerReturn1; + if (xmlSchemaValDecimalCompareWithInteger(&decimal, 0) < 0) + goto valIntegerReturn1; } if (val != NULL) { v = xmlSchemaNewValue(type->builtInType); if (v != NULL) { - v->value.decimal.lo = lo; - v->value.decimal.mi = mi; - v->value.decimal.hi = hi; - v->value.decimal.sign = 0; - v->value.decimal.frac = 0; - v->value.decimal.total = ret; + v->value.decimal = decimal; *val = v; } } + else if(decimal.str != NULL) + { + xmlFree(decimal.str); + } goto return0; + valIntegerReturn1: + if(decimal.str != NULL) + { + xmlFree(decimal.str); + } + goto return1; } } @@ -3628,139 +3669,16 @@ xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value, static int xmlSchemaCompareDecimals(xmlSchemaValPtr x, xmlSchemaValPtr y) { - xmlSchemaValPtr swp; - int order = 1, integx, integy, dlen; - unsigned long hi, mi, lo; - - /* - * First test: If x is -ve and not zero - */ - if ((x->value.decimal.sign) && - ((x->value.decimal.lo != 0) || - (x->value.decimal.mi != 0) || - (x->value.decimal.hi != 0))) { - /* - * Then if y is -ve and not zero reverse the compare - */ - if ((y->value.decimal.sign) && - ((y->value.decimal.lo != 0) || - (y->value.decimal.mi != 0) || - (y->value.decimal.hi != 0))) - order = -1; - /* - * Otherwise (y >= 0) we have the answer - */ - else - return (-1); - /* - * If x is not -ve and y is -ve we have the answer - */ - } else if ((y->value.decimal.sign) && - ((y->value.decimal.lo != 0) || - (y->value.decimal.mi != 0) || - (y->value.decimal.hi != 0))) { - return (1); - } - /* - * If it's not simply determined by a difference in sign, - * then we need to compare the actual values of the two nums. - * To do this, we start by looking at the integral parts. - * If the number of integral digits differ, then we have our - * answer. - */ - integx = x->value.decimal.total - x->value.decimal.frac; - integy = y->value.decimal.total - y->value.decimal.frac; - /* - * NOTE: We changed the "total" for values like "0.1" - * (or "-0.1" or ".1") to be 1, which was 2 previously. - * Therefore the special case, when such values are - * compared with 0, needs to be handled separately; - * otherwise a zero would be recognized incorrectly as - * greater than those values. This has the nice side effect - * that we gain an overall optimized comparison with zeroes. - * Note that a "0" has a "total" of 1 already. - */ - if (integx == 1) { - if (x->value.decimal.lo == 0) { - if (integy != 1) - return -order; - else if (y->value.decimal.lo != 0) - return -order; - else - return(0); - } - } - if (integy == 1) { - if (y->value.decimal.lo == 0) { - if (integx != 1) - return order; - else if (x->value.decimal.lo != 0) - return order; - else - return(0); - } - } - - if (integx > integy) - return order; - else if (integy > integx) - return -order; - - /* - * If the number of integral digits is the same for both numbers, - * then things get a little more complicated. We need to "normalize" - * the numbers in order to properly compare them. To do this, we - * look at the total length of each number (length => number of - * significant digits), and divide the "shorter" by 10 (decreasing - * the length) until they are of equal length. - */ - dlen = x->value.decimal.total - y->value.decimal.total; - if (dlen < 0) { /* y has more digits than x */ - swp = x; - hi = y->value.decimal.hi; - mi = y->value.decimal.mi; - lo = y->value.decimal.lo; - dlen = -dlen; - order = -order; - } else { /* x has more digits than y */ - swp = y; - hi = x->value.decimal.hi; - mi = x->value.decimal.mi; - lo = x->value.decimal.lo; - } - while (dlen > 8) { /* in effect, right shift by 10**8 */ - lo = mi; - mi = hi; - hi = 0; - dlen -= 8; - } - while (dlen > 0) { - unsigned long rem1, rem2; - rem1 = (hi % 10) * 100000000L; - hi = hi / 10; - rem2 = (mi % 10) * 100000000L; - mi = (mi + rem1) / 10; - lo = (lo + rem2) / 10; - dlen--; + int res = xmlSchemaValDecimalCompare(&x->value.decimal, &y->value.decimal); + if(res > 0) + { + return 1; } - if (hi > swp->value.decimal.hi) { - return order; - } else if (hi == swp->value.decimal.hi) { - if (mi > swp->value.decimal.mi) { - return order; - } else if (mi == swp->value.decimal.mi) { - if (lo > swp->value.decimal.lo) { - return order; - } else if (lo == swp->value.decimal.lo) { - if (x->value.decimal.total == y->value.decimal.total) { - return 0; - } else { - return order; - } - } - } + if(res < 0) + { + return -1; } - return -order; + return 0; } /** @@ -3947,6 +3865,24 @@ xmlSchemaCopyValue(xmlSchemaValPtr val) cur->value.base64.str = xmlStrdup(BAD_CAST val->value.base64.str); break; + case XML_SCHEMAS_DECIMAL: + case XML_SCHEMAS_INTEGER: + case XML_SCHEMAS_PINTEGER: + case XML_SCHEMAS_NPINTEGER: + case XML_SCHEMAS_NINTEGER: + case XML_SCHEMAS_NNINTEGER: + case XML_SCHEMAS_LONG: + case XML_SCHEMAS_BYTE: + case XML_SCHEMAS_SHORT: + case XML_SCHEMAS_INT: + case XML_SCHEMAS_UINT: + case XML_SCHEMAS_ULONG: + case XML_SCHEMAS_USHORT: + case XML_SCHEMAS_UBYTE: + cur = xmlSchemaDupVal(val); + if (val->value.decimal.str != NULL) + cur->value.decimal.str = xmlStrdup(BAD_CAST val->value.decimal.str); + break; default: cur = xmlSchemaDupVal(val); break; @@ -5312,9 +5248,10 @@ xmlSchemaGetFacetValueAsULong(xmlSchemaFacetPtr facet) /* * TODO: Check if this is a decimal. */ + char *discard; if (facet == NULL || facet->val == NULL) return 0; - return ((unsigned long) facet->val->value.decimal.lo); + return strtoul((const char*)facet->val->value.decimal.str+1, &discard, 10); } /** @@ -5342,21 +5279,21 @@ xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet, * (compare value.decimal.mi and value.decimal.hi as well?). */ if (facet->type == XML_SCHEMA_FACET_LENGTH) { - if (actualLen != facet->val->value.decimal.lo) { + if (actualLen != xmlSchemaGetFacetValueAsULong(facet)) { if (expectedLen != NULL) - *expectedLen = facet->val->value.decimal.lo; + *expectedLen = xmlSchemaGetFacetValueAsULong(facet); return (XML_SCHEMAV_CVC_LENGTH_VALID); } } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { - if (actualLen < facet->val->value.decimal.lo) { + if (actualLen < xmlSchemaGetFacetValueAsULong(facet)) { if (expectedLen != NULL) - *expectedLen = facet->val->value.decimal.lo; + *expectedLen = xmlSchemaGetFacetValueAsULong(facet); return (XML_SCHEMAV_CVC_MINLENGTH_VALID); } } else if (facet->type == XML_SCHEMA_FACET_MAXLENGTH) { - if (actualLen > facet->val->value.decimal.lo) { + if (actualLen > xmlSchemaGetFacetValueAsULong(facet)) { if (expectedLen != NULL) - *expectedLen = facet->val->value.decimal.lo; + *expectedLen = xmlSchemaGetFacetValueAsULong(facet); return (XML_SCHEMAV_CVC_MAXLENGTH_VALID); } } else @@ -5409,7 +5346,8 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet, if ((facet->val == NULL) || ((facet->val->type != XML_SCHEMAS_DECIMAL) && (facet->val->type != XML_SCHEMAS_NNINTEGER)) || - (facet->val->value.decimal.frac != 0)) { + !(xmlSchemaValDecimalIsInteger(&facet->val->value.decimal))) + { return(-1); } if ((val != NULL) && (val->type == XML_SCHEMAS_HEXBINARY)) @@ -5469,16 +5407,16 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet, } *length = (unsigned long) len; /* - * TODO: Return the whole expected value, i.e. "lo", "mi" and "hi". + * TODO: Return the whole expected value. (This may be possible now with xmlSchemaValDecimalCompareWithInteger) */ if (facet->type == XML_SCHEMA_FACET_LENGTH) { - if (len != facet->val->value.decimal.lo) + if (len != xmlSchemaGetFacetValueAsULong(facet)) return(XML_SCHEMAV_CVC_LENGTH_VALID); } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { - if (len < facet->val->value.decimal.lo) + if (len < xmlSchemaGetFacetValueAsULong(facet)) return(XML_SCHEMAV_CVC_MINLENGTH_VALID); } else { - if (len > facet->val->value.decimal.lo) + if (len > xmlSchemaGetFacetValueAsULong(facet)) return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); } @@ -5674,7 +5612,7 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, if ((facet->val == NULL) || ((facet->val->type != XML_SCHEMAS_DECIMAL) && (facet->val->type != XML_SCHEMAS_NNINTEGER)) || - (facet->val->value.decimal.frac != 0)) { + !xmlSchemaValDecimalIsInteger(&facet->val->value.decimal)) { return(-1); } if ((val != NULL) && (val->type == XML_SCHEMAS_HEXBINARY)) @@ -5723,14 +5661,13 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, } } if (facet->type == XML_SCHEMA_FACET_LENGTH) { - if (len != facet->val->value.decimal.lo) + if (len != xmlSchemaGetFacetValueAsULong(facet)) return(XML_SCHEMAV_CVC_LENGTH_VALID); } else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) { - if (len < facet->val->value.decimal.lo) + if (len < xmlSchemaGetFacetValueAsULong(facet)) return(XML_SCHEMAV_CVC_MINLENGTH_VALID); - } else { - if (len > facet->val->value.decimal.lo) - return(XML_SCHEMAV_CVC_MAXLENGTH_VALID); + } else if (len > xmlSchemaGetFacetValueAsULong(facet)) { + return (XML_SCHEMAV_CVC_MAXLENGTH_VALID); } break; } @@ -5740,7 +5677,7 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, if ((facet->val == NULL) || ((facet->val->type != XML_SCHEMAS_PINTEGER) && (facet->val->type != XML_SCHEMAS_NNINTEGER)) || - (facet->val->value.decimal.frac != 0)) { + !xmlSchemaValDecimalIsInteger(&facet->val->value.decimal)) { return(-1); } if ((val == NULL) || @@ -5761,11 +5698,11 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet, return(-1); } if (facet->type == XML_SCHEMA_FACET_TOTALDIGITS) { - if (val->value.decimal.total > facet->val->value.decimal.lo) + if (xmlSchemaValDecimalGetSignificantDigitCount(&val->value.decimal) > xmlSchemaGetFacetValueAsULong(facet)) return(XML_SCHEMAV_CVC_TOTALDIGITS_VALID); } else if (facet->type == XML_SCHEMA_FACET_FRACTIONDIGITS) { - if (val->value.decimal.frac > facet->val->value.decimal.lo) + if ((xmlSchemaValDecimalIsInteger(&val->value.decimal) ? 0 : val->value.decimal.fractionalPlaces) > xmlSchemaGetFacetValueAsULong(facet)) return(XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID); } break; @@ -5997,75 +5934,13 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue) BAD_CAST val->value.qname.uri); } break; - case XML_SCHEMAS_DECIMAL: - /* - * TODO: Lookout for a more simple implementation. - */ - if ((val->value.decimal.total == 1) && - (val->value.decimal.lo == 0)) { - *retValue = xmlStrdup(BAD_CAST "0.0"); - } else { - xmlSchemaValDecimal dec = val->value.decimal; - int bufsize; - char *buf = NULL, *offs; - - /* Add room for the decimal point as well. */ - bufsize = dec.total + 2; - if (dec.sign) - bufsize++; - /* Add room for leading/trailing zero. */ - if ((dec.frac == 0) || (dec.frac == dec.total)) - bufsize++; - buf = xmlMalloc(bufsize); - if (buf == NULL) - return(-1); - offs = buf; - if (dec.sign) - *offs++ = '-'; - if (dec.frac == dec.total) { - *offs++ = '0'; - *offs++ = '.'; - } - if (dec.hi != 0) - snprintf(offs, bufsize - (offs - buf), - "%lu%lu%lu", dec.hi, dec.mi, dec.lo); - else if (dec.mi != 0) - snprintf(offs, bufsize - (offs - buf), - "%lu%lu", dec.mi, dec.lo); - else - snprintf(offs, bufsize - (offs - buf), - "%lu", dec.lo); - - if (dec.frac != 0) { - if (dec.frac != dec.total) { - int diff = dec.total - dec.frac; - /* - * Insert the decimal point. - */ - memmove(offs + diff + 1, offs + diff, dec.frac +1); - offs[diff] = '.'; - } else { - unsigned int i = 0; - /* - * Insert missing zeroes behind the decimal point. - */ - while (*(offs + i) != 0) - i++; - if (i < dec.total) { - memmove(offs + (dec.total - i), offs, i +1); - memset(offs, '0', dec.total - i); - } - } - } else { - /* - * Append decimal point and zero. - */ - offs = buf + bufsize - 1; - *offs-- = 0; - *offs-- = '0'; - *offs-- = '.'; - } - *retValue = BAD_CAST buf; + case XML_SCHEMAS_DECIMAL: { + xmlChar *start = val->value.decimal.str; + if(start[0] == '+') + { + start += 1; + } + *retValue = xmlStrdup(start); } break; case XML_SCHEMAS_INTEGER: @@ -6080,40 +5955,20 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue) case XML_SCHEMAS_UINT: case XML_SCHEMAS_ULONG: case XML_SCHEMAS_USHORT: - case XML_SCHEMAS_UBYTE: - if ((val->value.decimal.total == 1) && - (val->value.decimal.lo == 0)) - *retValue = xmlStrdup(BAD_CAST "0"); - else { - xmlSchemaValDecimal dec = val->value.decimal; - int bufsize = dec.total + 1; - - /* Add room for the decimal point as well. */ - if (dec.sign) - bufsize++; - *retValue = xmlMalloc(bufsize); - if (*retValue == NULL) - return(-1); - if (dec.hi != 0) { - if (dec.sign) - snprintf((char *) *retValue, bufsize, - "-%lu%lu%lu", dec.hi, dec.mi, dec.lo); - else - snprintf((char *) *retValue, bufsize, - "%lu%lu%lu", dec.hi, dec.mi, dec.lo); - } else if (dec.mi != 0) { - if (dec.sign) - snprintf((char *) *retValue, bufsize, - "-%lu%lu", dec.mi, dec.lo); - else - snprintf((char *) *retValue, bufsize, - "%lu%lu", dec.mi, dec.lo); - } else { - if (dec.sign) - snprintf((char *) *retValue, bufsize, "-%lu", dec.lo); - else - snprintf((char *) *retValue, bufsize, "%lu", dec.lo); - } + case XML_SCHEMAS_UBYTE: { + xmlChar *start = val->value.decimal.str; + /* 2 = sign+NULL */ + size_t bufSize = val->value.decimal.integralPlaces+2; + if(start[0] == '+') + { + start += 1; + bufSize -= 1; + } + *retValue = xmlMalloc(bufSize); + if(*retValue) { + /* no need to limit string length in format, it will only print bufSize-1 chars anyways */ + snprintf((char*)*retValue, bufSize, "%s", start); + } } break; case XML_SCHEMAS_BOOLEAN: From 619e2808b5ac01b02e5fca6c4be4597a0a69ac2d Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 30 Apr 2024 15:53:08 +0200 Subject: [PATCH 420/504] tree: Don't call xmlNewCharRef in xmlNodeParseContent xmlNewCharRef also tries to handle strings like '&name;' but in xmlNodeParseContentInternal, we really want to use the possibly invalid name without modification. Otherwise, content like '&"' could create a reference to a predefined entity. --- tree.c | 72 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/tree.c b/tree.c index e86c25a53..b385663ec 100644 --- a/tree.c +++ b/tree.c @@ -55,6 +55,9 @@ int __xmlRegisterCallbacks = 0; * * ************************************************************************/ +static xmlNodePtr +xmlNewEntityRef(xmlDocPtr doc, xmlChar *name); + static xmlNsPtr xmlNewReconciledNs(xmlNodePtr tree, xmlNsPtr ns); @@ -1339,7 +1342,8 @@ xmlNodeParseContentInternal(const xmlDoc *doc, xmlNodePtr parent, /* * Create a new REFERENCE_REF node */ - node = xmlNewCharRef((xmlDocPtr) doc, val); + node = xmlNewEntityRef((xmlDocPtr) doc, val); + val = NULL; if (node == NULL) goto out; node->parent = parent; @@ -2363,6 +2367,42 @@ xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns, } #endif /* LIBXML_TREE_ENABLED */ +/** + * xmlNewEntityRef: + * @doc: the target document (optional) + * @name: the entity name + * + * Create an empty entity reference node. This function doesn't attempt + * to look up the entity in @doc. + * + * @name is consumed. + * + * Returns a pointer to the new node object or NULL if arguments are + * invalid or a memory allocation failed. + */ +static xmlNodePtr +xmlNewEntityRef(xmlDocPtr doc, xmlChar *name) { + xmlNodePtr cur; + + /* + * Allocate a new node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + xmlFree(name); + return(NULL); + } + memset(cur, 0, sizeof(xmlNode)); + cur->type = XML_ENTITY_REF_NODE; + cur->doc = doc; + cur->name = name; + + if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) + xmlRegisterNodeDefaultValue(cur); + + return(cur); +} + /** * xmlNewCharRef: * @doc: the target document (optional) @@ -2381,41 +2421,25 @@ xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns, */ xmlNodePtr xmlNewCharRef(xmlDocPtr doc, const xmlChar *name) { - xmlNodePtr cur; + xmlChar *copy; if (name == NULL) return(NULL); - /* - * Allocate a new node and fill the fields. - */ - cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); - if (cur == NULL) - return(NULL); - memset(cur, 0, sizeof(xmlNode)); - cur->type = XML_ENTITY_REF_NODE; - - cur->doc = doc; if (name[0] == '&') { int len; name++; len = xmlStrlen(name); if (name[len - 1] == ';') - cur->name = xmlStrndup(name, len - 1); + copy = xmlStrndup(name, len - 1); else - cur->name = xmlStrndup(name, len); + copy = xmlStrndup(name, len); } else - cur->name = xmlStrdup(name); - if (cur->name == NULL) - goto error; - - if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) - xmlRegisterNodeDefaultValue(cur); - return(cur); + copy = xmlStrdup(name); + if (copy == NULL) + return(NULL); -error: - xmlFreeNode(cur); - return(NULL); + return(xmlNewEntityRef(doc, copy)); } /** From b8597f46df99b7a819e2c14ea1c24f649c0b149e Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 30 Apr 2024 15:58:01 +0200 Subject: [PATCH 421/504] tree: Handle predefined entities in xmlBufGetEntityRefContent It's possible to create references to predefined entities using the tree API. This edge case was exposed by making predefined entities const in commit 63ce5f9a. --- testparser.c | 20 ++++++++++++++++++++ tree.c | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/testparser.c b/testparser.c index 923a0f2b6..d19e9ea52 100644 --- a/testparser.c +++ b/testparser.c @@ -59,6 +59,25 @@ testUnsupportedEncoding(void) { return err; } +static int +testNodeGetContent(void) { + xmlDocPtr doc; + xmlChar *content; + int err = 0; + + doc = xmlReadDoc(BAD_CAST "", NULL, NULL, 0); + xmlAddChild(doc->children, xmlNewReference(doc, BAD_CAST "lt")); + content = xmlNodeGetContent((xmlNodePtr) doc); + if (strcmp((char *) content, "<") != 0) { + fprintf(stderr, "xmlNodeGetContent failed\n"); + err = 1; + } + xmlFree(content); + xmlFreeDoc(doc); + + return err; +} + #ifdef LIBXML_SAX1_ENABLED static int testBalancedChunk(void) { @@ -373,6 +392,7 @@ main(void) { err |= testStandaloneWithEncoding(); err |= testUnsupportedEncoding(); + err |= testNodeGetContent(); #ifdef LIBXML_SAX1_ENABLED err |= testBalancedChunk(); #endif diff --git a/tree.c b/tree.c index b385663ec..71408be08 100644 --- a/tree.c +++ b/tree.c @@ -5504,6 +5504,16 @@ xmlBufGetEntityRefContent(xmlBufPtr buf, const xmlNode *ref) { return; } + /* + * The parser should always expand predefined entities but it's + * possible to create references to predefined entities using + * the tree API. + */ + if (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY) { + xmlBufCat(buf, ent->content); + return; + } + if (ent->flags & XML_ENT_EXPANDING) return; From d2f623d183745081127a4761c581ca0a90466b00 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 30 Apr 2024 16:36:44 +0200 Subject: [PATCH 422/504] reader: Report malloc failure in xmlTextReaderConstValue --- xmlreader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmlreader.c b/xmlreader.c index 31ff0caa9..5a709f378 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -3640,12 +3640,12 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) { xmlBufGetNodeContent(reader->buffer, node); ret = xmlBufContent(reader->buffer); if (ret == NULL) { + xmlTextReaderErrMemory(reader); /* error on the buffer best to reallocate */ xmlBufFree(reader->buffer); reader->buffer = xmlBufCreateSize(100); xmlBufSetAllocationScheme(reader->buffer, XML_BUFFER_ALLOC_DOUBLEIT); - ret = BAD_CAST ""; } return(ret); } From e637953527c41abc4a1df766685734316232f615 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 30 Apr 2024 17:00:01 +0200 Subject: [PATCH 423/504] Remove references to old mailing list --- MAINTAINERS.md | 4 ++-- README.md | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 9dd0502b3..76ba488c2 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -82,8 +82,8 @@ Create a new GitLab release on ### Announce the release -Announce the release by sending an email to the mailing list at -xml@gnome.org. +Announce the release on https://discourse.gnome.org under topics 'libxml2' +and 'announcements'. ## Breaking the ABI diff --git a/README.md b/README.md index 0256d5f97..664bd3714 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Now you can run the test suite with: make check -Please report test failures to the mailing list or bug tracker. +Please report test failures to the bug tracker. Then you can install the library: @@ -159,10 +159,7 @@ Use of this feature is discouraged. The current version of the code can be found in GNOME's GitLab at at . The best way to get involved -is by creating issues and merge requests on GitLab. Alternatively, you can -start discussions and send patches to the mailing list. If you want to -work with patches, please format them with git-format-patch and use plain -text attachments. +is by creating issues and merge requests on GitLab. All code must conform to C89 and pass the GitLab CI tests. Add regression tests if possible. From ae23a4ce56fc500ec5bc204c720b6d7f1c656004 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 30 Apr 2024 17:26:28 +0200 Subject: [PATCH 424/504] unicode: Deprecate most xmlUCSIs* functions These don't seem to be used by downstream code. --- genUnicode.py | 4 +- include/libxml/xmlunicode.h | 166 +++++++++++++++++++++++++++++++++++- python/generator.py | 5 +- 3 files changed, 171 insertions(+), 4 deletions(-) diff --git a/genUnicode.py b/genUnicode.py index c6e13a854..cf50bfef3 100755 --- a/genUnicode.py +++ b/genUnicode.py @@ -373,7 +373,7 @@ for block in bkeys: name = block.replace('-', '') - header.write("XMLPUBFUN int xmlUCSIs%s\t(int code);\n" % name) + header.write("XML_DEPRECATED\nXMLPUBFUN int xmlUCSIs%s\t(int code);\n" % name) output.write("/**\n * xmlUCSIs%s:\n * @code: UCS code point\n" % (name)) output.write(" *\n * Check whether the character is part of %s UCS Block\n"% (block)) @@ -413,7 +413,7 @@ for name in ckeys: ranges = Categories[name] - header.write("XMLPUBFUN int xmlUCSIsCat%s\t(int code);\n" % name) + header.write("XML_DEPRECATED\nXMLPUBFUN int xmlUCSIsCat%s\t(int code);\n" % name) output.write("/**\n * xmlUCSIsCat%s:\n * @code: UCS code point\n" % (name)) output.write(" *\n * Check whether the character is part of %s UCS Category\n"% (name)) diff --git a/include/libxml/xmlunicode.h b/include/libxml/xmlunicode.h index 2e50a49f9..b6d795b26 100644 --- a/include/libxml/xmlunicode.h +++ b/include/libxml/xmlunicode.h @@ -7,7 +7,7 @@ * http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1.html * using the genUnicode.py Python script. * - * Generation date: Mon Mar 27 11:09:52 2006 + * Generation date: Tue Apr 30 17:30:38 2024 * Sources: Blocks-4.0.1.txt UnicodeData-4.0.1.txt * Author: Daniel Veillard */ @@ -23,172 +23,336 @@ extern "C" { #endif +XML_DEPRECATED XMLPUBFUN int xmlUCSIsAegeanNumbers (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsAlphabeticPresentationForms (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsArabic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsArabicPresentationFormsA (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsArabicPresentationFormsB (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsArmenian (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsArrows (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBasicLatin (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBengali (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBlockElements (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBopomofo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBopomofoExtended (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBoxDrawing (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBraillePatterns (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsBuhid (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsByzantineMusicalSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKCompatibility (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKCompatibilityForms (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographs (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographsSupplement (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKRadicalsSupplement (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKSymbolsandPunctuation (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKUnifiedIdeographs (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionA (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionB (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCherokee (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCombiningDiacriticalMarks (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCombiningDiacriticalMarksforSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCombiningHalfMarks (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCombiningMarksforSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsControlPictures (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCurrencySymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCypriotSyllabary (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCyrillic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCyrillicSupplement (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsDeseret (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsDevanagari (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsDingbats (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsEnclosedAlphanumerics (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsEnclosedCJKLettersandMonths (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsEthiopic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGeneralPunctuation (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGeometricShapes (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGeorgian (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGothic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGreek (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGreekExtended (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGreekandCoptic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGujarati (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsGurmukhi (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHalfwidthandFullwidthForms (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHangulCompatibilityJamo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHangulJamo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHangulSyllables (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHanunoo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHebrew (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHighPrivateUseSurrogates (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHighSurrogates (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsHiragana (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsIPAExtensions (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsIdeographicDescriptionCharacters (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsKanbun (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsKangxiRadicals (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsKannada (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsKatakana (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsKatakanaPhoneticExtensions (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsKhmer (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsKhmerSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLao (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLatin1Supplement (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLatinExtendedA (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLatinExtendedB (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLatinExtendedAdditional (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLetterlikeSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLimbu (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLinearBIdeograms (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLinearBSyllabary (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsLowSurrogates (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMalayalam (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMathematicalAlphanumericSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMathematicalOperators (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsA (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsB (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMiscellaneousSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMiscellaneousSymbolsandArrows (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMiscellaneousTechnical (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMongolian (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMusicalSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsMyanmar (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsNumberForms (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsOgham (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsOldItalic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsOpticalCharacterRecognition (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsOriya (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsOsmanya (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsPhoneticExtensions (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsPrivateUse (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsPrivateUseArea (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsRunic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsShavian (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSinhala (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSmallFormVariants (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSpacingModifierLetters (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSpecials (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSuperscriptsandSubscripts (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSupplementalArrowsA (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSupplementalArrowsB (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSupplementalMathematicalOperators (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaA (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaB (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsSyriac (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTagalog (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTagbanwa (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTags (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTaiLe (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTaiXuanJingSymbols (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTamil (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTelugu (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsThaana (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsThai (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsTibetan (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsUgaritic (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsUnifiedCanadianAboriginalSyllabics (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsVariationSelectors (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsVariationSelectorsSupplement (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsYiRadicals (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsYiSyllables (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsYijingHexagramSymbols (int code); XMLPUBFUN int xmlUCSIsBlock (int code, const char *block); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatC (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatCc (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatCf (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatCo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatCs (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatL (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatLl (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatLm (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatLo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatLt (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatLu (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatM (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatMc (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatMe (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatMn (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatN (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatNd (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatNl (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatNo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatP (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatPc (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatPd (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatPe (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatPf (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatPi (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatPo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatPs (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatS (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatSc (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatSk (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatSm (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatSo (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatZ (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatZl (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatZp (int code); +XML_DEPRECATED XMLPUBFUN int xmlUCSIsCatZs (int code); XMLPUBFUN int xmlUCSIsCat (int code, const char *cat); diff --git a/python/generator.py b/python/generator.py index 11f58c732..466a2e68a 100755 --- a/python/generator.py +++ b/python/generator.py @@ -492,7 +492,10 @@ def print_function_wrapper(name, output, export, include): # Don't delete the function entry in the caller. return 1 - is_deprecated = name in deprecated_funcs + if name.startswith('xmlUCSIs'): + is_deprecated = name != 'xmlUCSIsBlock' and name != 'xmlUCSIsCat' + else: + is_deprecated = name in deprecated_funcs c_call = "" format="" From 39e5b35bd0976b9a3da896179f503a579a5fb4c4 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 2 May 2024 22:06:19 +0200 Subject: [PATCH 425/504] parser: Don't create undeclared entity refs in substitution mode We never want to create entity reference nodes if entity substitution is enabled. This also applies to undeclared entities. --- parser.c | 5 ++--- result/noent/undeclared-entity.xml | 2 +- result/noent/undeclared-entity.xml.sax2 | 1 - result/undeclared-entity.xml.rde | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/parser.c b/parser.c index bfe96fd39..9e58379ad 100644 --- a/parser.c +++ b/parser.c @@ -7365,10 +7365,9 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { if (ent == NULL) { /* * Create a reference for undeclared entities. - * TODO: Should we really create a reference if entity - * substitution is enabled? */ - if ((ctxt->sax != NULL) && + if ((ctxt->replaceEntities == 0) && + (ctxt->sax != NULL) && (ctxt->disableSAX == 0) && (ctxt->sax->reference != NULL)) { ctxt->sax->reference(ctxt->userData, name); diff --git a/result/noent/undeclared-entity.xml b/result/noent/undeclared-entity.xml index 1fd092f7b..3db97bc15 100644 --- a/result/noent/undeclared-entity.xml +++ b/result/noent/undeclared-entity.xml @@ -3,5 +3,5 @@ - &undeclared; + diff --git a/result/noent/undeclared-entity.xml.sax2 b/result/noent/undeclared-entity.xml.sax2 index 56f3f3d90..60eaaea2e 100644 --- a/result/noent/undeclared-entity.xml.sax2 +++ b/result/noent/undeclared-entity.xml.sax2 @@ -16,7 +16,6 @@ SAX.characters( SAX.startElementNs(elem, NULL, NULL, 0, 0, 0) SAX.getEntity(undeclared) SAX.warning: Entity 'undeclared' not defined -SAX.reference(undeclared) SAX.endElementNs(elem, NULL, NULL) SAX.characters( , 1) diff --git a/result/undeclared-entity.xml.rde b/result/undeclared-entity.xml.rde index 29ebf6220..065f91bee 100644 --- a/result/undeclared-entity.xml.rde +++ b/result/undeclared-entity.xml.rde @@ -7,7 +7,6 @@ 1 14 #text 0 1 1 1 elem 0 0 -2 5 undeclared 0 0 1 15 elem 0 0 1 14 #text 0 1 From fdc5ff36571ec7b19b991d5ed4126369095c1cb8 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 2 May 2024 16:23:04 +0200 Subject: [PATCH 426/504] parser: Always throw entity errors if external DTD is loaded When parsing with XML_PARSE_DTDLOAD, missing entities are always an error. Also consolidate behavior when validating. See b717abdd. --- parser.c | 75 +++++++++++++--------------------- python/tests/input_callback.py | 4 +- result/ent7.sax | 1 - result/ent7.sax2 | 1 - result/noent/ent7.sax2 | 1 - result/noent/xml2.sax2 | 1 - result/xml2.sax | 1 - result/xml2.sax2 | 1 - runtest.c | 10 ++++- 9 files changed, 38 insertions(+), 57 deletions(-) diff --git a/parser.c b/parser.c index 9e58379ad..f44927384 100644 --- a/parser.c +++ b/parser.c @@ -7602,11 +7602,22 @@ xmlLookupGeneralEntity(xmlParserCtxtPtr ctxt, const xmlChar *name, int inAttr) { * standalone='yes'. */ if (ent == NULL) { - if ((ctxt->standalone == 1) || + if (((!ctxt->validate) && (ctxt->loadsubset)) || + (ctxt->standalone == 1) || ((ctxt->hasExternalSubset == 0) && (ctxt->hasPErefs == 0))) { xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, "Entity '%s' not defined\n", name); + } else if (ctxt->validate) { + /* + * [ VC: Entity Declared ] + * In a document with an external subset or external + * parameter entities with "standalone='no'", ... + * ... The declaration of a parameter entity must + * precede any reference to it... + */ + xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, + "Entity '%s' not defined\n", name, NULL); } else { xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, "Entity '%s' not defined\n", name, NULL); @@ -7823,37 +7834,19 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) (ctxt->sax->getParameterEntity != NULL)) entity = ctxt->sax->getParameterEntity(ctxt->userData, name); if (entity == NULL) { - /* - * [ WFC: Entity Declared ] - * In a document without any DTD, a document with only an - * internal DTD subset which contains no parameter entity - * references, or a document with "standalone='yes'", ... - * ... The declaration of a parameter entity must precede - * any reference to it... - */ - if ((ctxt->standalone == 1) || - ((ctxt->hasExternalSubset == 0) && - (ctxt->hasPErefs == 0))) { + if (((!ctxt->validate) && (ctxt->loadsubset)) || + (ctxt->standalone == 1)) { xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, "PEReference: %%%s; not found\n", name); - } else { - /* - * [ VC: Entity Declared ] - * In a document with an external subset or external - * parameter entities with "standalone='no'", ... - * ... The declaration of a parameter entity must - * precede any reference to it... - */ - if ((ctxt->validate) && (ctxt->vctxt.error != NULL)) { - xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", - name, NULL); - } else - xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", + } else if (ctxt->validate) { + xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, + "PEReference: %%%s; not found\n", + name, NULL); + } else { + xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, + "PEReference: %%%s; not found\n", name, NULL); - ctxt->valid = 0; } } else { /* @@ -8098,30 +8091,18 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { (ctxt->sax->getParameterEntity != NULL)) entity = ctxt->sax->getParameterEntity(ctxt->userData, name); if (entity == NULL) { - /* - * [ WFC: Entity Declared ] - * In a document without any DTD, a document with only an - * internal DTD subset which contains no parameter entity - * references, or a document with "standalone='yes'", ... - * ... The declaration of a parameter entity must precede - * any reference to it... - */ - if ((ctxt->standalone == 1) || - ((ctxt->hasExternalSubset == 0) && (ctxt->hasPErefs == 0))) { + if (((!ctxt->validate) && (ctxt->loadsubset)) || + (ctxt->standalone == 1)) { xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, "PEReference: %%%s; not found\n", name); - } else { - /* - * [ VC: Entity Declared ] - * In a document with an external subset or external - * parameter entities with "standalone='no'", ... - * ... The declaration of a parameter entity must - * precede any reference to it... - */ + } else if (ctxt->validate) { + xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, + "PEReference: %%%s; not found\n", + name, NULL); + } else { xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, "PEReference: %%%s; not found\n", name, NULL); - ctxt->valid = 0; } } else { /* diff --git a/python/tests/input_callback.py b/python/tests/input_callback.py index c1ba0859b..6d5ec0da0 100755 --- a/python/tests/input_callback.py +++ b/python/tests/input_callback.py @@ -101,7 +101,7 @@ def my_ctx_error_cb(arg, msg, severity, reserved): exp_status="loaded", exp_err=[ ( 3, 'failed to load "http://example.com/dtds/sample.dtd": Attempt to load network entity\n'), ( -1, "Attempt to load network entity: http://example.com/dtds/sample.dtd"), - ( 3, "Entity 'sample.entity' not defined\n") + ( 4, "Entity 'sample.entity' not defined\n") ]) # Register a catalog (also accessible via pystr://) and retry @@ -114,7 +114,7 @@ def my_ctx_error_cb(arg, msg, severity, reserved): test_callback=lambda: libxml2.popInputCallbacks(), exp_status="loaded", exp_err=[ ( 3, "failed to load \"py://strings/dtds/sample.dtd\": No such file or directory\n"), - ( 3, "Entity 'sample.entity' not defined\n") + ( 4, "Entity 'sample.entity' not defined\n") ]) # Try to load the document again diff --git a/result/ent7.sax b/result/ent7.sax index 934610068..40c64eb17 100644 --- a/result/ent7.sax +++ b/result/ent7.sax @@ -1,4 +1,3 @@ -xmlParseDocument returned error 26 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(item, , ) diff --git a/result/ent7.sax2 b/result/ent7.sax2 index 4654c3df8..ddd9c4a8c 100644 --- a/result/ent7.sax2 +++ b/result/ent7.sax2 @@ -1,4 +1,3 @@ -xmlParseDocument returned error 26 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(item, , ) diff --git a/result/noent/ent7.sax2 b/result/noent/ent7.sax2 index 77dd7fff5..3236e36a1 100644 --- a/result/noent/ent7.sax2 +++ b/result/noent/ent7.sax2 @@ -1,4 +1,3 @@ -xmlParseDocument returned error 26 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(item, , ) diff --git a/result/noent/xml2.sax2 b/result/noent/xml2.sax2 index dae52c894..edf748bdb 100644 --- a/result/noent/xml2.sax2 +++ b/result/noent/xml2.sax2 @@ -1,4 +1,3 @@ -xmlParseDocument returned error 26 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(test, , ) diff --git a/result/xml2.sax b/result/xml2.sax index 52c0e6bf3..c52e078c6 100644 --- a/result/xml2.sax +++ b/result/xml2.sax @@ -1,4 +1,3 @@ -xmlParseDocument returned error 26 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(test, , ) diff --git a/result/xml2.sax2 b/result/xml2.sax2 index 52a8b1fe9..1bbd66f11 100644 --- a/result/xml2.sax2 +++ b/result/xml2.sax2 @@ -1,4 +1,3 @@ -xmlParseDocument returned error 26 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(test, , ) diff --git a/runtest.c b/runtest.c index 97ae53090..4ee8182e2 100644 --- a/runtest.c +++ b/runtest.c @@ -11,6 +11,8 @@ * daniel@veillard.com */ +#define XML_DEPRECATED + #include "libxml.h" #include #ifdef HAVE_UNISTD_H @@ -1601,9 +1603,11 @@ oldParseTest(const char *filename, const char *result, * base of the test, parse with the old API */ #ifdef LIBXML_SAX1_ENABLED + xmlGetWarningsDefaultValue = 0; doc = xmlParseFile(filename); + xmlGetWarningsDefaultValue = 1; #else - doc = xmlReadFile(filename, NULL, 0); + doc = xmlReadFile(filename, NULL, XML_PARSE_NOWARNING); #endif if (doc == NULL) return(1); @@ -1622,9 +1626,11 @@ oldParseTest(const char *filename, const char *result, * Parse the saved result to make sure the round trip is okay */ #ifdef LIBXML_SAX1_ENABLED + xmlGetWarningsDefaultValue = 0; doc = xmlParseFile(temp); + xmlGetWarningsDefaultValue = 1; #else - doc = xmlReadFile(temp, NULL, 0); + doc = xmlReadFile(temp, NULL, XML_PARSE_NOWARNING); #endif if (doc == NULL) return(1); From 71a7a33e18fce3822405be2c4ce40d03064d48ea Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 3 May 2024 00:44:42 +0200 Subject: [PATCH 427/504] parser: Fix base URI of internal parameter entities Search parent inputs of internal parameter entities for base URI. Fixes a long-standing bug, which manifested in a different way after commit 955c177f. Reproduce with xmllint --noent xmlconf/eduni/errata-2e/E18.xml --- SAX2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SAX2.c b/SAX2.c index a347023ba..b8011fec5 100644 --- a/SAX2.c +++ b/SAX2.c @@ -559,9 +559,14 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, if ((ent->URI == NULL) && (systemId != NULL)) { xmlChar *URI; const char *base = NULL; + int i; - if (ctxt->input != NULL) - base = ctxt->input->filename; + for (i = ctxt->inputNr - 1; i >= 0; i--) { + if (ctxt->inputTab[i]->filename != NULL) { + base = ctxt->inputTab[i]->filename; + break; + } + } if (xmlBuildURISafe(systemId, (const xmlChar *) base, &URI) < 0) { xmlSAX2ErrMemory(ctxt); From 422ae4623a0b07f1dac14ecf9438c717d00a71a7 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 5 May 2024 15:20:15 +0200 Subject: [PATCH 428/504] xmllint: Make some strings const --- debugXML.c | 2 +- include/libxml/debugXML.h | 2 +- xmllint.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/debugXML.c b/debugXML.c index 75d0bf262..ed56b0f88 100644 --- a/debugXML.c +++ b/debugXML.c @@ -2792,7 +2792,7 @@ xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer, * using a environment similar to a UNIX commandline. */ void -xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input, +xmlShell(xmlDocPtr doc, const char *filename, xmlShellReadlineFunc input, FILE * output) { char prompt[500] = "/ > "; diff --git a/include/libxml/debugXML.h b/include/libxml/debugXML.h index 827468736..1332dd73d 100644 --- a/include/libxml/debugXML.h +++ b/include/libxml/debugXML.h @@ -203,7 +203,7 @@ XMLPUBFUN int */ XMLPUBFUN void xmlShell (xmlDocPtr doc, - char *filename, + const char *filename, xmlShellReadlineFunc input, FILE *output); diff --git a/xmllint.c b/xmllint.c index 1bc119e01..31fe90a5e 100644 --- a/xmllint.c +++ b/xmllint.c @@ -127,17 +127,17 @@ static int oldout = 0; #ifdef LIBXML_VALID_ENABLED static int valid = 0; static int postvalid = 0; -static char * dtdvalid = NULL; -static char * dtdvalidfpi = NULL; +static const char *dtdvalid = NULL; +static const char *dtdvalidfpi = NULL; #endif #ifdef LIBXML_SCHEMAS_ENABLED -static char * relaxng = NULL; +static const char *relaxng = NULL; static xmlRelaxNGPtr relaxngschemas = NULL; -static char * schema = NULL; +static const char *schema = NULL; static xmlSchemaPtr wxschemas = NULL; #endif #ifdef LIBXML_SCHEMATRON_ENABLED -static char * schematron = NULL; +static const char *schematron = NULL; static xmlSchematronPtr wxschematron = NULL; #endif static int repeat = 0; @@ -158,7 +158,7 @@ static int pushsize = 4096; static int memory = 0; #endif static int testIO = 0; -static char *encoding = NULL; +static const char *encoding = NULL; #ifdef LIBXML_XINCLUDE_ENABLED static int xinclude = 0; #endif @@ -1768,7 +1768,7 @@ static void processNode(xmlTextReaderPtr reader) { #endif } -static void streamFile(char *filename) { +static void streamFile(const char *filename) { xmlTextReaderPtr reader; int ret; #ifdef HAVE_MMAP @@ -2116,7 +2116,7 @@ static void doXPathQuery(xmlDocPtr doc, const char *query) { * Tree Test processing * * * ************************************************************************/ -static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { +static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { xmlDocPtr doc = NULL; #ifdef LIBXML_TREE_ENABLED xmlDocPtr tmp; From a4c2b7233fdff127b619fcff1a0b6b00acdb7ef7 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 5 May 2024 17:26:31 +0200 Subject: [PATCH 429/504] io: Don't set close callback in xmlParserInputBufferCreateFd --- HTMLparser.c | 2 -- parser.c | 2 -- xmlIO.c | 1 - 3 files changed, 5 deletions(-) diff --git a/HTMLparser.c b/HTMLparser.c index e2ae3b11f..11ccef524 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -6488,7 +6488,6 @@ htmlReadFd(int fd, const char *url, const char *encoding, int options) htmlCtxtUseOptions(ctxt, options); input = xmlNewInputFd(ctxt, url, fd, encoding, 0); - input->buf->closecallback = NULL; doc = htmlCtxtParseDocument(ctxt, input); @@ -6660,7 +6659,6 @@ htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd, htmlCtxtUseOptions(ctxt, options); input = xmlNewInputFd(ctxt, URL, fd, encoding, 0); - input->buf->closecallback = NULL; return(htmlCtxtParseDocument(ctxt, input)); } diff --git a/parser.c b/parser.c index f44927384..f296f3280 100644 --- a/parser.c +++ b/parser.c @@ -13872,7 +13872,6 @@ xmlReadFd(int fd, const char *URL, const char *encoding, int options) xmlCtxtUseOptions(ctxt, options); input = xmlNewInputFd(ctxt, URL, fd, encoding, 0); - input->buf->closecallback = NULL; doc = xmlCtxtParseDocument(ctxt, input); @@ -14053,7 +14052,6 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, xmlCtxtUseOptions(ctxt, options); input = xmlNewInputFd(ctxt, URL, fd, encoding, 0); - input->buf->closecallback = NULL; return(xmlCtxtParseDocument(ctxt, input)); } diff --git a/xmlIO.c b/xmlIO.c index 56a183a99..6789c7ee8 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -1902,7 +1902,6 @@ xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc) { if (ret != NULL) { ret->context = (void *) (ptrdiff_t) fd; ret->readcallback = xmlFdRead; - ret->closecallback = xmlFdClose; } return(ret); From a39e862b96eb62fc380dc5a2c4e8ef90f3683e5a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 5 May 2024 18:16:11 +0200 Subject: [PATCH 430/504] xmllint: Add explicit cast for -fsanitize=integer --- xmllint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmllint.c b/xmllint.c index 31fe90a5e..7e0d0e4e1 100644 --- a/xmllint.c +++ b/xmllint.c @@ -1249,7 +1249,7 @@ charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) if (noout) return; for (i = 0;(i Date: Sun, 5 May 2024 18:16:44 +0200 Subject: [PATCH 431/504] reader: Don't call xmlCtxtErrMemory with NULL ctxt This can happen in "walker" mode. --- xmlreader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xmlreader.c b/xmlreader.c index 5a709f378..627d96ddb 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -40,6 +40,7 @@ #endif #include "private/buf.h" +#include "private/error.h" #include "private/tree.h" #include "private/parser.h" #ifdef LIBXML_XINCLUDE_ENABLED @@ -181,7 +182,10 @@ static void xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur); static void xmlTextReaderErrMemory(xmlTextReaderPtr reader) { - xmlCtxtErrMemory(reader->ctxt); + if (reader->ctxt != NULL) + xmlCtxtErrMemory(reader->ctxt); + else + xmlRaiseMemoryError(NULL, NULL, NULL, XML_FROM_PARSER, NULL); reader->mode = XML_TEXTREADER_MODE_ERROR; reader->state = XML_TEXTREADER_ERROR; } From 20a0de95b4e0ae2fcb59a7da57f95b8ff01285b2 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 00:08:54 +0200 Subject: [PATCH 432/504] xmllint: Fix --pushsmall option This is only a debugging aid but also useful when fuzzing. --- xmllint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xmllint.c b/xmllint.c index 7e0d0e4e1..1451b5eb6 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2216,8 +2216,8 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { if (push) { FILE *f; int ret; - int res, size = 1024; - char chars[1024]; + int res; + char chars[4096]; xmlParserCtxtPtr ctxt; /* '-' Usually means stdin - */ @@ -2244,7 +2244,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { xmlCtxtUseOptions(ctxt, options); if (maxAmpl > 0) xmlCtxtSetMaxAmplification(ctxt, maxAmpl); - while ((res = fread(chars, 1, size, f)) > 0) { + while ((res = fread(chars, 1, pushsize, f)) > 0) { xmlParseChunk(ctxt, chars, res, 0); } xmlParseChunk(ctxt, chars, 0, 1); From 826baf00d4a8d95d9b9c81e1dd9bfda7f6d9e35d Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 00:29:07 +0200 Subject: [PATCH 433/504] xmllint: Fix --insert option Make sure that parent is an element when calling xmlValidGetValidElements. --- xmllint.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xmllint.c b/xmllint.c index 1451b5eb6..d740b767b 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2492,7 +2492,10 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { if (doc->children != NULL) { node = doc->children; - while ((node != NULL) && (node->last == NULL)) node = node->next; + while ((node != NULL) && + ((node->type != XML_ELEMENT_NODE) || + (node->last == NULL))) + node = node->next; if (node != NULL) { nb = xmlValidGetValidElements(node->last, NULL, list, 256); if (nb < 0) { From d644a23e8f5f83f4130b473d816e1fe3957e5c9d Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 5 May 2024 23:37:03 +0200 Subject: [PATCH 434/504] fuzz: Improve xml.dict - Add standalone declaration - Add doctype declaration - Expand ATTLIST matrix in xml.dict --- fuzz/xml.dict | 58 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/fuzz/xml.dict b/fuzz/xml.dict index a539e6adf..094bf5797 100644 --- a/fuzz/xml.dict +++ b/fuzz/xml.dict @@ -1,4 +1,5 @@ xml_decl="" +xml_decl_standalone="" xml_decl_latin1="" elem_start_end="" @@ -18,6 +19,10 @@ comment="" pi="" +doctype="" +doctype_system="" +doctype_system="" + elem_decl_any="" elem_decl_empty="" elem_decl_children="" @@ -30,19 +35,46 @@ elem_quant_any="*" elem_quant_opt="?" elem_quant_some="+" -attlist_decl_cdata_req="" -attlist_decl_cdata_imp="" -attlist_decl_cdata_def="" -attlist_decl_cdata_fix="" -attlist_decl_id="" -attlist_decl_idref="" -attlist_decl_idrefs="" -attlist_decl_entity="" -attlist_decl_entities="" -attlist_decl_nmtoken="" -attlist_decl_nmtokens="" -attlist_decl_enum="" -attlist_decl_notation="" +attr_decl_cdata_req="" +attr_decl_cdata_imp="" +attr_decl_cdata_def="" +attr_decl_cdata_fix="" +attr_decl_id_imp="" +attr_decl_id_req="" +attr_decl_id_def="" +attr_decl_id_fix="" +attr_decl_idref_imp="" +attr_decl_idref_req="" +attr_decl_idref_def="" +attr_decl_idref_fix="" +attr_decl_idrefs_imp="" +attr_decl_idrefs_req="" +attr_decl_idrefs_def="" +attr_decl_idrefs_fix="" +attr_decl_entity_imp="" +attr_decl_entity_req="" +attr_decl_entity_def="" +attr_decl_entity_fix="" +attr_decl_entities_imp="" +attr_decl_entities_req="" +attr_decl_entities_def="" +attr_decl_entities_fix="" +attr_decl_nmtoken_imp="" +attr_decl_nmtoken_req="" +attr_decl_nmtoken_def="" +attr_decl_nmtoken_fix="" +attr_decl_nmtokens_imp="" +attr_decl_nmtokens_req="" +attr_decl_nmtokens_def="" +attr_decl_nmtokens_fix="" +attr_decl_enum_imp="" +attr_decl_enum_req="" +attr_decl_enum_def="" +attr_decl_enum_fix="" +attr_decl_notation_imp="" +attr_decl_notation_req="" +attr_decl_notation_def="" +attr_decl_notation_fix="" include_sect="" ignore_sect="" From f4826c84122ece98bd693b999c507a7d00d30228 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 00:33:19 +0200 Subject: [PATCH 435/504] xmllint: Add macro for error stream Prepare for fuzzing. --- xmllint.c | 286 +++++++++++++++++++++++++++--------------------------- 1 file changed, 144 insertions(+), 142 deletions(-) diff --git a/xmllint.c b/xmllint.c index d740b767b..d2a3398a5 100644 --- a/xmllint.c +++ b/xmllint.c @@ -81,6 +81,8 @@ #include #endif +#define ERR_STREAM stderr + #ifndef XML_XML_DEFAULT_CATALOG #define XML_XML_DEFAULT_CATALOG "file://" SYSCONFDIR "/xml/catalog" #endif @@ -221,7 +223,7 @@ void parsePath(const xmlChar *path) { return; while (*path != 0) { if (nbpaths >= MAX_PATHS) { - fprintf(stderr, "MAX_PATHS reached: too many paths\n"); + fprintf(ERR_STREAM, "MAX_PATHS reached: too many paths\n"); return; } cur = path; @@ -276,7 +278,7 @@ xmllintExternalEntityLoader(const char *URL, const char *ID, ctxt->sax->error = err; if (load_trace) { fprintf \ - (stderr, + (ERR_STREAM, "Loaded URL=\"%s\" ID=\"%s\"\n", URL ? URL : "(null)", ID ? ID : "(null)"); @@ -299,7 +301,7 @@ xmllintExternalEntityLoader(const char *URL, const char *ID, ctxt->sax->error = err; if (load_trace) { fprintf \ - (stderr, + (ERR_STREAM, "Loaded URL=\"%s\" ID=\"%s\"\n", newURL, ID ? ID : "(null)"); @@ -330,7 +332,7 @@ xmllintExternalEntityLoader(const char *URL, const char *ID, static void OOM(void) { - fprintf(stderr, "Ran out of memory needs > %d bytes\n", maxmem); + fprintf(ERR_STREAM, "Ran out of memory needs > %d bytes\n", maxmem); progresult = XMLLINT_ERR_MEM; } @@ -442,10 +444,10 @@ endTimer(const char *fmt, ...) msec += (end.tv_usec - begin.tv_usec) / 1000; va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + vfprintf(ERR_STREAM, fmt, ap); va_end(ap); - fprintf(stderr, " took %ld ms\n", msec); + fprintf(ERR_STREAM, " took %ld ms\n", msec); } #else /* @@ -473,9 +475,9 @@ endTimer(const char *fmt, ...) msec = ((end - begin) * 1000) / CLOCKS_PER_SEC; va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + vfprintf(ERR_STREAM, fmt, ap); va_end(ap); - fprintf(stderr, " took %ld ms\n", msec); + fprintf(ERR_STREAM, " took %ld ms\n", msec); } #endif /************************************************************************ @@ -497,7 +499,7 @@ xmlHTMLEncodeSend(void) { memset(&buffer[sizeof(buffer)-4], 0, 4); result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer); if (result) { - fprintf(stderr, "%s", result); + fprintf(ERR_STREAM, "%s", result); xmlFree(result); } buffer[0] = 0; @@ -513,7 +515,7 @@ xmlHTMLEncodeSend(void) { static void xmlHTMLPrintFileInfo(xmlParserInputPtr input) { int len; - fprintf(stderr, "

    "); + fprintf(ERR_STREAM, "

    "); len = strlen(buffer); if (input != NULL) { @@ -541,7 +543,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) { int n; if (input == NULL) return; - fprintf(stderr, "

    \n");
    +    fprintf(ERR_STREAM, "
    \n");
         cur = input->cur;
         base = input->base;
         while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
    @@ -573,7 +575,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
         len = strlen(buffer);
         snprintf(&buffer[len], sizeof(buffer) - len, "^\n");
         xmlHTMLEncodeSend();
    -    fprintf(stderr, "
    "); + fprintf(ERR_STREAM, "
    "); } /** @@ -601,13 +603,13 @@ xmlHTMLError(void *ctx, const char *msg, ...) xmlHTMLPrintFileInfo(input); - fprintf(stderr, "error: "); + fprintf(ERR_STREAM, "error: "); va_start(args, msg); len = strlen(buffer); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); - fprintf(stderr, "

    \n"); + fprintf(ERR_STREAM, "

    \n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); @@ -639,13 +641,13 @@ xmlHTMLWarning(void *ctx, const char *msg, ...) xmlHTMLPrintFileInfo(input); - fprintf(stderr, "warning: "); + fprintf(ERR_STREAM, "warning: "); va_start(args, msg); len = strlen(buffer); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); - fprintf(stderr, "

    \n"); + fprintf(ERR_STREAM, "

    \n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); @@ -675,13 +677,13 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...) xmlHTMLPrintFileInfo(input); - fprintf(stderr, "validity error: "); + fprintf(ERR_STREAM, "validity error: "); len = strlen(buffer); va_start(args, msg); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); - fprintf(stderr, "

    \n"); + fprintf(ERR_STREAM, "

    \n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); @@ -712,13 +714,13 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...) xmlHTMLPrintFileInfo(input); - fprintf(stderr, "validity warning: "); + fprintf(ERR_STREAM, "validity warning: "); va_start(args, msg); len = strlen(buffer); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); va_end(args); xmlHTMLEncodeSend(); - fprintf(stderr, "

    \n"); + fprintf(ERR_STREAM, "

    \n"); xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); @@ -1629,13 +1631,13 @@ testSAX(const char *filename) { if (repeat == 0) { if (ret == 0) { if (!quiet) { - fprintf(stderr, "%s validates\n", filename); + fprintf(ERR_STREAM, "%s validates\n", filename); } } else if (ret > 0) { - fprintf(stderr, "%s fails to validate\n", filename); + fprintf(ERR_STREAM, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { - fprintf(stderr, "%s validation generated an internal error\n", + fprintf(ERR_STREAM, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } @@ -1663,7 +1665,7 @@ testSAX(const char *filename) { xmlCtxtReadFile(ctxt, filename, NULL, options); if (ctxt->myDoc != NULL) { - fprintf(stderr, "SAX generated a doc !\n"); + fprintf(ERR_STREAM, "SAX generated a doc !\n"); xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL; } @@ -1731,7 +1733,7 @@ static void processNode(xmlTextReaderPtr reader) { xmlTextReaderConstLocalName(reader), xmlTextReaderConstNamespaceUri(reader)); if (ret < 0) { - fprintf(stderr, "xmlStreamPush() failure\n"); + fprintf(ERR_STREAM, "xmlStreamPush() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } else if (ret != match) { @@ -1741,13 +1743,13 @@ static void processNode(xmlTextReaderPtr reader) { xmlTextReaderCurrentNode(reader)); } #endif - fprintf(stderr, + fprintf(ERR_STREAM, "xmlPatternMatch and xmlStreamPush disagree\n"); if (path != NULL) - fprintf(stderr, " pattern %s node %s\n", + fprintf(ERR_STREAM, " pattern %s node %s\n", pattern, path); else - fprintf(stderr, " pattern %s node %s\n", + fprintf(ERR_STREAM, " pattern %s node %s\n", pattern, xmlTextReaderConstName(reader)); } @@ -1756,7 +1758,7 @@ static void processNode(xmlTextReaderPtr reader) { ((type == XML_READER_TYPE_ELEMENT) && (empty))) { ret = xmlStreamPop(patstream); if (ret < 0) { - fprintf(stderr, "xmlStreamPop() failure\n"); + fprintf(ERR_STREAM, "xmlStreamPop() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } @@ -1784,7 +1786,7 @@ static void streamFile(const char *filename) { base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (base == (void *) MAP_FAILED) { close(fd); - fprintf(stderr, "mmap failure for file %s\n", filename); + fprintf(ERR_STREAM, "mmap failure for file %s\n", filename); progresult = XMLLINT_ERR_RDFILE; return; } @@ -1803,7 +1805,7 @@ static void streamFile(const char *filename) { if (patstream != NULL) { ret = xmlStreamPush(patstream, NULL, NULL); if (ret < 0) { - fprintf(stderr, "xmlStreamPush() failure\n"); + fprintf(ERR_STREAM, "xmlStreamPush() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } @@ -1829,7 +1831,7 @@ static void streamFile(const char *filename) { } ret = xmlTextReaderRelaxNGValidate(reader, relaxng); if (ret < 0) { - fprintf(stderr, + fprintf(ERR_STREAM, "Relax-NG schema %s failed to compile\n", relaxng); progresult = XMLLINT_ERR_SCHEMACOMP; relaxng = NULL; @@ -1844,7 +1846,7 @@ static void streamFile(const char *filename) { } ret = xmlTextReaderSchemaValidate(reader, schema); if (ret < 0) { - fprintf(stderr, + fprintf(ERR_STREAM, "XSD schema %s failed to compile\n", schema); progresult = XMLLINT_ERR_SCHEMACOMP; schema = NULL; @@ -1888,7 +1890,7 @@ static void streamFile(const char *filename) { #ifdef LIBXML_VALID_ENABLED if (valid) { if (xmlTextReaderIsValid(reader) != 1) { - fprintf(stderr, + fprintf(ERR_STREAM, "Document %s does not validate\n", filename); progresult = XMLLINT_ERR_VALID; } @@ -1897,11 +1899,11 @@ static void streamFile(const char *filename) { #ifdef LIBXML_SCHEMAS_ENABLED if ((relaxng != NULL) || (schema != NULL)) { if (xmlTextReaderIsValid(reader) != 1) { - fprintf(stderr, "%s fails to validate\n", filename); + fprintf(ERR_STREAM, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { if (!quiet) { - fprintf(stderr, "%s validates\n", filename); + fprintf(ERR_STREAM, "%s validates\n", filename); } } } @@ -1911,11 +1913,11 @@ static void streamFile(const char *filename) { */ xmlFreeTextReader(reader); if (ret != 0) { - fprintf(stderr, "%s : failed to parse\n", filename); + fprintf(ERR_STREAM, "%s : failed to parse\n", filename); progresult = XMLLINT_ERR_UNCLASS; } } else { - fprintf(stderr, "Unable to open %s\n", filename); + fprintf(ERR_STREAM, "Unable to open %s\n", filename); progresult = XMLLINT_ERR_UNCLASS; } #ifdef LIBXML_PATTERN_ENABLED @@ -1944,7 +1946,7 @@ static void walkDoc(xmlDocPtr doc) { root = xmlDocGetRootElement(doc); if (root == NULL ) { - fprintf(stderr, + fprintf(ERR_STREAM, "Document does not have a root element"); progresult = XMLLINT_ERR_UNCLASS; return; @@ -1960,7 +1962,7 @@ static void walkDoc(xmlDocPtr doc) { patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict, 0, &namespaces[0]); if (patternc == NULL) { - fprintf(stderr, + fprintf(ERR_STREAM, "Pattern %s failed to compile\n", pattern); progresult = XMLLINT_ERR_SCHEMAPAT; pattern = NULL; @@ -1971,7 +1973,7 @@ static void walkDoc(xmlDocPtr doc) { if (patstream != NULL) { ret = xmlStreamPush(patstream, NULL, NULL); if (ret < 0) { - fprintf(stderr, "xmlStreamPush() failure\n"); + fprintf(ERR_STREAM, "xmlStreamPush() failure\n"); xmlFreeStreamCtxt(patstream); patstream = NULL; } @@ -1998,11 +2000,11 @@ static void walkDoc(xmlDocPtr doc) { } xmlFreeTextReader(reader); if (ret != 0) { - fprintf(stderr, "failed to walk through the doc\n"); + fprintf(ERR_STREAM, "failed to walk through the doc\n"); progresult = XMLLINT_ERR_UNCLASS; } } else { - fprintf(stderr, "Failed to crate a reader from the document\n"); + fprintf(ERR_STREAM, "Failed to crate a reader from the document\n"); progresult = XMLLINT_ERR_UNCLASS; } #ifdef LIBXML_PATTERN_ENABLED @@ -2032,13 +2034,13 @@ static void doXPathDump(xmlXPathObjectPtr cur) { if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) { progresult = XMLLINT_ERR_XPATH_EMPTY; if (!quiet) { - fprintf(stderr, "XPath set is empty\n"); + fprintf(ERR_STREAM, "XPath set is empty\n"); } break; } buf = xmlOutputBufferCreateFile(stdout, NULL); if (buf == NULL) { - fprintf(stderr, "Out of memory for XPath\n"); + fprintf(ERR_STREAM, "Out of memory for XPath\n"); progresult = XMLLINT_ERR_MEM; return; } @@ -2077,11 +2079,11 @@ static void doXPathDump(xmlXPathObjectPtr cur) { printf("%s\n", (const char *) cur->stringval); break; case XPATH_UNDEFINED: - fprintf(stderr, "XPath Object is uninitialized\n"); + fprintf(ERR_STREAM, "XPath Object is uninitialized\n"); progresult = XMLLINT_ERR_XPATH; break; default: - fprintf(stderr, "XPath object of unexpected type\n"); + fprintf(ERR_STREAM, "XPath object of unexpected type\n"); progresult = XMLLINT_ERR_XPATH; break; } @@ -2093,7 +2095,7 @@ static void doXPathQuery(xmlDocPtr doc, const char *query) { ctxt = xmlXPathNewContext(doc); if (ctxt == NULL) { - fprintf(stderr, "Out of memory for XPath\n"); + fprintf(ERR_STREAM, "Out of memory for XPath\n"); progresult = XMLLINT_ERR_MEM; return; } @@ -2102,7 +2104,7 @@ static void doXPathQuery(xmlDocPtr doc, const char *query) { xmlXPathFreeContext(ctxt); if (res == NULL) { - fprintf(stderr, "XPath evaluation failure\n"); + fprintf(ERR_STREAM, "XPath evaluation failure\n"); progresult = XMLLINT_ERR_XPATH; return; } @@ -2151,7 +2153,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { } else { f = fopen(filename, "rb"); if (f == NULL) { - fprintf(stderr, "Can't open %s\n", filename); + fprintf(ERR_STREAM, "Can't open %s\n", filename); progresult = XMLLINT_ERR_UNCLASS; return; } @@ -2189,7 +2191,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (base == (void *) MAP_FAILED) { close(fd); - fprintf(stderr, "mmap failure for file %s\n", filename); + fprintf(ERR_STREAM, "mmap failure for file %s\n", filename); progresult = XMLLINT_ERR_RDFILE; return; } @@ -2226,7 +2228,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { } else { f = fopen(filename, "rb"); if (f == NULL) { - fprintf(stderr, "Can't open %s\n", filename); + fprintf(ERR_STREAM, "Can't open %s\n", filename); progresult = XMLLINT_ERR_UNCLASS; return; } @@ -2315,7 +2317,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (base == (void *) MAP_FAILED) { close(fd); - fprintf(stderr, "mmap failure for file %s\n", filename); + fprintf(ERR_STREAM, "mmap failure for file %s\n", filename); progresult = XMLLINT_ERR_RDFILE; return; } @@ -2325,7 +2327,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { ctxt = xmlNewParserCtxt(); if (ctxt == NULL) { - fprintf(stderr, "out of memory\n"); + fprintf(ERR_STREAM, "out of memory\n"); progresult = XMLLINT_ERR_MEM; return; } @@ -2381,7 +2383,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { ctxt = xmlNewParserCtxt(); if (ctxt == NULL) { - fprintf(stderr, "out of memory\n"); + fprintf(ERR_STREAM, "out of memory\n"); progresult = XMLLINT_ERR_MEM; return; } @@ -2499,14 +2501,14 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { if (node != NULL) { nb = xmlValidGetValidElements(node->last, NULL, list, 256); if (nb < 0) { - fprintf(stderr, "could not get valid list of elements\n"); + fprintf(ERR_STREAM, "could not get valid list of elements\n"); } else if (nb == 0) { - fprintf(stderr, "No element can be inserted under root\n"); + fprintf(ERR_STREAM, "No element can be inserted under root\n"); } else { - fprintf(stderr, "%d element types can be inserted under root:\n", + fprintf(ERR_STREAM, "%d element types can be inserted under root:\n", nb); for (i = 0;i < nb;i++) { - fprintf(stderr, "%s\n", (char *) list[i]); + fprintf(ERR_STREAM, "%s\n", (char *) list[i]); } } } @@ -2564,7 +2566,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { if (output != NULL) fclose(out); } else { - fprintf(stderr, "failed to open %s\n", output); + fprintf(ERR_STREAM, "failed to open %s\n", output); progresult = XMLLINT_ERR_OUT; } } @@ -2581,11 +2583,11 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result); if (size >= 0) { if (write(1, result, size) == -1) { - fprintf(stderr, "Can't write data\n"); + fprintf(ERR_STREAM, "Can't write data\n"); } xmlFree(result); } else { - fprintf(stderr, "Failed to canonicalize\n"); + fprintf(ERR_STREAM, "Failed to canonicalize\n"); progresult = XMLLINT_ERR_OUT; } } else if (canonical_11) { @@ -2595,11 +2597,11 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result); if (size >= 0) { if (write(1, result, size) == -1) { - fprintf(stderr, "Can't write data\n"); + fprintf(ERR_STREAM, "Can't write data\n"); } xmlFree(result); } else { - fprintf(stderr, "Failed to canonicalize\n"); + fprintf(ERR_STREAM, "Failed to canonicalize\n"); progresult = XMLLINT_ERR_OUT; } } else @@ -2610,11 +2612,11 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result); if (size >= 0) { if (write(1, result, size) == -1) { - fprintf(stderr, "Can't write data\n"); + fprintf(ERR_STREAM, "Can't write data\n"); } xmlFree(result); } else { - fprintf(stderr, "Failed to canonicalize\n"); + fprintf(ERR_STREAM, "Failed to canonicalize\n"); progresult = XMLLINT_ERR_OUT; } } else @@ -2637,11 +2639,11 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { xmlDocDumpMemory(doc, &result, &len); } if (result == NULL) { - fprintf(stderr, "Failed to save\n"); + fprintf(ERR_STREAM, "Failed to save\n"); progresult = XMLLINT_ERR_OUT; } else { if (write(1, result, len) == -1) { - fprintf(stderr, "Can't write data\n"); + fprintf(ERR_STREAM, "Can't write data\n"); } xmlFree(result); } @@ -2661,14 +2663,14 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { encoding); } if (ret < 0) { - fprintf(stderr, "failed save to %s\n", + fprintf(ERR_STREAM, "failed save to %s\n", output ? output : "-"); progresult = XMLLINT_ERR_OUT; } } else if (format == 1) { ret = xmlSaveFormatFile(output ? output : "-", doc, 1); if (ret < 0) { - fprintf(stderr, "failed save to %s\n", + fprintf(ERR_STREAM, "failed save to %s\n", output ? output : "-"); progresult = XMLLINT_ERR_OUT; } @@ -2686,7 +2688,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { if (output != NULL) fclose(out); } else { - fprintf(stderr, "failed to open %s\n", output); + fprintf(ERR_STREAM, "failed to open %s\n", output); progresult = XMLLINT_ERR_OUT; } } @@ -2711,7 +2713,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { if (ctxt != NULL) { if (xmlSaveDoc(ctxt, doc) < 0) { - fprintf(stderr, "failed save to %s\n", + fprintf(ERR_STREAM, "failed save to %s\n", output ? output : "-"); progresult = XMLLINT_ERR_OUT; } @@ -2737,7 +2739,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { if (output != NULL) fclose(out); } else { - fprintf(stderr, "failed to open %s\n", output); + fprintf(ERR_STREAM, "failed to open %s\n", output); progresult = XMLLINT_ERR_OUT; } } @@ -2764,17 +2766,17 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { } if (dtd == NULL) { if (dtdvalid != NULL) - fprintf(stderr, + fprintf(ERR_STREAM, "Could not parse DTD %s\n", dtdvalid); else - fprintf(stderr, + fprintf(ERR_STREAM, "Could not parse DTD %s\n", dtdvalidfpi); progresult = XMLLINT_ERR_DTD; } else { xmlValidCtxtPtr cvp; if ((cvp = xmlNewValidCtxt()) == NULL) { - fprintf(stderr, + fprintf(ERR_STREAM, "Couldn't allocate validation context\n"); progresult = XMLLINT_ERR_MEM; xmlFreeDtd(dtd); @@ -2786,11 +2788,11 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { } if (!xmlValidateDtd(cvp, doc, dtd)) { if (dtdvalid != NULL) - fprintf(stderr, + fprintf(ERR_STREAM, "Document %s does not validate against %s\n", filename, dtdvalid); else - fprintf(stderr, + fprintf(ERR_STREAM, "Document %s does not validate against %s\n", filename, dtdvalidfpi); progresult = XMLLINT_ERR_VALID; @@ -2805,7 +2807,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { xmlValidCtxtPtr cvp; if ((cvp = xmlNewValidCtxt()) == NULL) { - fprintf(stderr, + fprintf(ERR_STREAM, "Couldn't allocate validation context\n"); progresult = XMLLINT_ERR_MEM; xmlFreeDoc(doc); @@ -2816,7 +2818,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { startTimer(); } if (!xmlValidateDocument(cvp, doc)) { - fprintf(stderr, + fprintf(ERR_STREAM, "Document %s does not validate\n", filename); progresult = XMLLINT_ERR_VALID; } @@ -2851,13 +2853,13 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { ret = xmlSchematronValidateDoc(ctxt, doc); if (ret == 0) { if (!quiet) { - fprintf(stderr, "%s validates\n", filename); + fprintf(ERR_STREAM, "%s validates\n", filename); } } else if (ret > 0) { - fprintf(stderr, "%s fails to validate\n", filename); + fprintf(ERR_STREAM, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { - fprintf(stderr, "%s validation generated an internal error\n", + fprintf(ERR_STREAM, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } @@ -2885,13 +2887,13 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { ret = xmlRelaxNGValidateDoc(ctxt, doc); if (ret == 0) { if (!quiet) { - fprintf(stderr, "%s validates\n", filename); + fprintf(ERR_STREAM, "%s validates\n", filename); } } else if (ret > 0) { - fprintf(stderr, "%s fails to validate\n", filename); + fprintf(ERR_STREAM, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { - fprintf(stderr, "%s validation generated an internal error\n", + fprintf(ERR_STREAM, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } @@ -2916,13 +2918,13 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { ret = xmlSchemaValidateDoc(ctxt, doc); if (ret == 0) { if (!quiet) { - fprintf(stderr, "%s validates\n", filename); + fprintf(ERR_STREAM, "%s validates\n", filename); } } else if (ret > 0) { - fprintf(stderr, "%s fails to validate\n", filename); + fprintf(ERR_STREAM, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { - fprintf(stderr, "%s validation generated an internal error\n", + fprintf(ERR_STREAM, "%s validation generated an internal error\n", filename); progresult = XMLLINT_ERR_VALID; } @@ -2936,7 +2938,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { #ifdef LIBXML_DEBUG_ENABLED #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) if ((debugent) && (!html)) - xmlDebugDumpEntities(stderr, doc); + xmlDebugDumpEntities(ERR_STREAM, doc); #endif #endif @@ -2959,40 +2961,40 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { ************************************************************************/ static void showVersion(const char *name) { - fprintf(stderr, "%s: using libxml version %s\n", name, xmlParserVersion); - fprintf(stderr, " compiled with: "); - if (xmlHasFeature(XML_WITH_THREAD)) fprintf(stderr, "Threads "); - if (xmlHasFeature(XML_WITH_TREE)) fprintf(stderr, "Tree "); - if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(stderr, "Output "); - if (xmlHasFeature(XML_WITH_PUSH)) fprintf(stderr, "Push "); - if (xmlHasFeature(XML_WITH_READER)) fprintf(stderr, "Reader "); - if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns "); - if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer "); - if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 "); - if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP "); - if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP "); - if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid "); - if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML "); - if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy "); - if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N "); - if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog "); - if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath "); - if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer "); - if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude "); - if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv "); - if (xmlHasFeature(XML_WITH_ICU)) fprintf(stderr, "ICU "); - if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X "); - if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode "); - if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); - if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata "); - if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr "); - if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas "); - if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron "); - if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules "); - if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug "); - if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); - if (xmlHasFeature(XML_WITH_LZMA)) fprintf(stderr, "Lzma "); - fprintf(stderr, "\n"); + fprintf(ERR_STREAM, "%s: using libxml version %s\n", name, xmlParserVersion); + fprintf(ERR_STREAM, " compiled with: "); + if (xmlHasFeature(XML_WITH_THREAD)) fprintf(ERR_STREAM, "Threads "); + if (xmlHasFeature(XML_WITH_TREE)) fprintf(ERR_STREAM, "Tree "); + if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(ERR_STREAM, "Output "); + if (xmlHasFeature(XML_WITH_PUSH)) fprintf(ERR_STREAM, "Push "); + if (xmlHasFeature(XML_WITH_READER)) fprintf(ERR_STREAM, "Reader "); + if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(ERR_STREAM, "Patterns "); + if (xmlHasFeature(XML_WITH_WRITER)) fprintf(ERR_STREAM, "Writer "); + if (xmlHasFeature(XML_WITH_SAX1)) fprintf(ERR_STREAM, "SAXv1 "); + if (xmlHasFeature(XML_WITH_FTP)) fprintf(ERR_STREAM, "FTP "); + if (xmlHasFeature(XML_WITH_HTTP)) fprintf(ERR_STREAM, "HTTP "); + if (xmlHasFeature(XML_WITH_VALID)) fprintf(ERR_STREAM, "DTDValid "); + if (xmlHasFeature(XML_WITH_HTML)) fprintf(ERR_STREAM, "HTML "); + if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(ERR_STREAM, "Legacy "); + if (xmlHasFeature(XML_WITH_C14N)) fprintf(ERR_STREAM, "C14N "); + if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(ERR_STREAM, "Catalog "); + if (xmlHasFeature(XML_WITH_XPATH)) fprintf(ERR_STREAM, "XPath "); + if (xmlHasFeature(XML_WITH_XPTR)) fprintf(ERR_STREAM, "XPointer "); + if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(ERR_STREAM, "XInclude "); + if (xmlHasFeature(XML_WITH_ICONV)) fprintf(ERR_STREAM, "Iconv "); + if (xmlHasFeature(XML_WITH_ICU)) fprintf(ERR_STREAM, "ICU "); + if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(ERR_STREAM, "ISO8859X "); + if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(ERR_STREAM, "Unicode "); + if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(ERR_STREAM, "Regexps "); + if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(ERR_STREAM, "Automata "); + if (xmlHasFeature(XML_WITH_EXPR)) fprintf(ERR_STREAM, "Expr "); + if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(ERR_STREAM, "Schemas "); + if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(ERR_STREAM, "Schematron "); + if (xmlHasFeature(XML_WITH_MODULES)) fprintf(ERR_STREAM, "Modules "); + if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(ERR_STREAM, "Debug "); + if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(ERR_STREAM, "Zlib "); + if (xmlHasFeature(XML_WITH_LZMA)) fprintf(ERR_STREAM, "Lzma "); + fprintf(ERR_STREAM, "\n"); } static void usage(FILE *f, const char *name) { @@ -3124,11 +3126,11 @@ parseInteger(const char *ctxt, const char *str, errno = 0; val = strtoul(str, &strEnd, 10); if (errno == EINVAL || *strEnd != 0) { - fprintf(stderr, "%s: invalid integer: %s\n", ctxt, str); + fprintf(ERR_STREAM, "%s: invalid integer: %s\n", ctxt, str); exit(XMLLINT_ERR_UNCLASS); } if (errno != 0 || val < min || val > max) { - fprintf(stderr, "%s: integer out of range: %s\n", ctxt, str); + fprintf(ERR_STREAM, "%s: integer out of range: %s\n", ctxt, str); exit(XMLLINT_ERR_UNCLASS); } @@ -3142,7 +3144,7 @@ main(int argc, char **argv) { int version = 0; if (argc <= 1) { - usage(stderr, argv[0]); + usage(ERR_STREAM, argv[0]); return(XMLLINT_ERR_UNCLASS); } @@ -3155,7 +3157,7 @@ main(int argc, char **argv) { (!strcmp(argv[i], "--maxmem"))) { i++; if (i >= argc) { - fprintf(stderr, "maxmem: missing integer value\n"); + fprintf(ERR_STREAM, "maxmem: missing integer value\n"); return(XMLLINT_ERR_UNCLASS); } errno = 0; @@ -3493,13 +3495,13 @@ main(int argc, char **argv) { (!strcmp(argv[i], "--max-ampl"))) { i++; if (i >= argc) { - fprintf(stderr, "max-ampl: missing integer value\n"); + fprintf(ERR_STREAM, "max-ampl: missing integer value\n"); return(XMLLINT_ERR_UNCLASS); } maxAmpl = parseInteger("max-ampl", argv[i], 1, UINT_MAX); } else { - fprintf(stderr, "Unknown option %s\n", argv[i]); - usage(stderr, argv[0]); + fprintf(ERR_STREAM, "Unknown option %s\n", argv[i]); + usage(ERR_STREAM, argv[0]); return(XMLLINT_ERR_UNCLASS); } } @@ -3513,7 +3515,7 @@ main(int argc, char **argv) { if (catal != NULL) { xmlLoadCatalogs(catal); } else { - fprintf(stderr, "Variable $SGML_CATALOG_FILES not set\n"); + fprintf(ERR_STREAM, "Variable $SGML_CATALOG_FILES not set\n"); } } } @@ -3536,14 +3538,14 @@ main(int argc, char **argv) { if ((noblanks != 0) || (format == 1)) options |= XML_PARSE_NOBLANKS; if ((htmlout) && (!nowrap)) { - fprintf(stderr, + fprintf(ERR_STREAM, "\n"); - fprintf(stderr, + fprintf(ERR_STREAM, "%s output\n", argv[0]); - fprintf(stderr, + fprintf(ERR_STREAM, "

    %s output

    \n", argv[0]); } @@ -3568,7 +3570,7 @@ main(int argc, char **argv) { } wxschematron = xmlSchematronParse(ctxt); if (wxschematron == NULL) { - fprintf(stderr, + fprintf(ERR_STREAM, "Schematron schema %s failed to compile\n", schematron); progresult = XMLLINT_ERR_SCHEMACOMP; schematron = NULL; @@ -3599,7 +3601,7 @@ main(int argc, char **argv) { } relaxngschemas = xmlRelaxNGParse(ctxt); if (relaxngschemas == NULL) { - fprintf(stderr, + fprintf(ERR_STREAM, "Relax-NG schema %s failed to compile\n", relaxng); progresult = XMLLINT_ERR_SCHEMACOMP; relaxng = NULL; @@ -3625,7 +3627,7 @@ main(int argc, char **argv) { } wxschemas = xmlSchemaParse(ctxt); if (wxschemas == NULL) { - fprintf(stderr, + fprintf(ERR_STREAM, "WXS schema %s failed to compile\n", schema); progresult = XMLLINT_ERR_SCHEMACOMP; schema = NULL; @@ -3640,7 +3642,7 @@ main(int argc, char **argv) { if ((pattern != NULL) && (walker == 0)) { patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL); if (patternc == NULL) { - fprintf(stderr, + fprintf(ERR_STREAM, "Pattern %s failed to compile\n", pattern); progresult = XMLLINT_ERR_SCHEMAPAT; pattern = NULL; @@ -3772,10 +3774,10 @@ main(int argc, char **argv) { if (generate) parseAndPrintFile(NULL, NULL); if ((htmlout) && (!nowrap)) { - fprintf(stderr, "\n"); + fprintf(ERR_STREAM, "\n"); } if ((files == 0) && (!generate) && (version == 0)) { - usage(stderr, argv[0]); + usage(ERR_STREAM, argv[0]); progresult = XMLLINT_ERR_UNCLASS; } #ifdef LIBXML_SCHEMATRON_ENABLED From a7854e264656cfcd2a74645ff2f95aa4274a059e Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 01:30:18 +0200 Subject: [PATCH 436/504] http: Don't pass NULL pointer as memcpy source --- nanohttp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nanohttp.c b/nanohttp.c index e508292af..5c6789305 100644 --- a/nanohttp.c +++ b/nanohttp.c @@ -1219,8 +1219,10 @@ xmlNanoHTTPRead(void *ctx, void *dest, int len) { } if (ctxt->inptr - ctxt->inrptr < len) len = ctxt->inptr - ctxt->inrptr; - memcpy(dest, ctxt->inrptr, len); - ctxt->inrptr += len; + if (len > 0) { + memcpy(dest, ctxt->inrptr, len); + ctxt->inrptr += len; + } return(len); } From 907a5a48854e49bd6c4adec082bfdcc4f8e9fd4a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 02:34:01 +0200 Subject: [PATCH 437/504] xmllint: Fix memory leak in walkDoc --- xmllint.c | 82 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/xmllint.c b/xmllint.c index d2a3398a5..317f24290 100644 --- a/xmllint.c +++ b/xmllint.c @@ -1939,45 +1939,51 @@ static void walkDoc(xmlDocPtr doc) { int ret; #ifdef LIBXML_PATTERN_ENABLED - xmlNodePtr root; - const xmlChar *namespaces[22]; - int i; - xmlNsPtr ns; - - root = xmlDocGetRootElement(doc); - if (root == NULL ) { - fprintf(ERR_STREAM, - "Document does not have a root element"); - progresult = XMLLINT_ERR_UNCLASS; - return; - } - for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) { - namespaces[i++] = ns->href; - namespaces[i++] = ns->prefix; - } - namespaces[i++] = NULL; - namespaces[i] = NULL; - if (pattern != NULL) { - patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict, - 0, &namespaces[0]); + xmlNodePtr root; + const xmlChar *namespaces[22]; + int i; + xmlNsPtr ns; + + root = xmlDocGetRootElement(doc); + if (root == NULL ) { + fprintf(ERR_STREAM, + "Document does not have a root element"); + progresult = XMLLINT_ERR_UNCLASS; + return; + } + for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) { + namespaces[i++] = ns->href; + namespaces[i++] = ns->prefix; + } + namespaces[i++] = NULL; + namespaces[i] = NULL; + + ret = xmlPatternCompileSafe((const xmlChar *) pattern, doc->dict, + 0, &namespaces[0], &patternc); if (patternc == NULL) { - fprintf(ERR_STREAM, - "Pattern %s failed to compile\n", pattern); - progresult = XMLLINT_ERR_SCHEMAPAT; - pattern = NULL; - } - } - if (patternc != NULL) { - patstream = xmlPatternGetStreamCtxt(patternc); - if (patstream != NULL) { - ret = xmlStreamPush(patstream, NULL, NULL); - if (ret < 0) { - fprintf(ERR_STREAM, "xmlStreamPush() failure\n"); - xmlFreeStreamCtxt(patstream); - patstream = NULL; + if (ret < 0) { + progresult = XMLLINT_ERR_MEM; + } else { + fprintf(ERR_STREAM, + "Pattern %s failed to compile\n", pattern); + progresult = XMLLINT_ERR_SCHEMAPAT; } + goto error; } + + patstream = xmlPatternGetStreamCtxt(patternc); + if (patstream == NULL) { + progresult = XMLLINT_ERR_MEM; + goto error; + } + + ret = xmlStreamPush(patstream, NULL, NULL); + if (ret < 0) { + fprintf(ERR_STREAM, "xmlStreamPush() failure\n"); + progresult = XMLLINT_ERR_MEM; + goto error; + } } #endif /* LIBXML_PATTERN_ENABLED */ reader = xmlReaderWalker(doc); @@ -2007,7 +2013,13 @@ static void walkDoc(xmlDocPtr doc) { fprintf(ERR_STREAM, "Failed to crate a reader from the document\n"); progresult = XMLLINT_ERR_UNCLASS; } + #ifdef LIBXML_PATTERN_ENABLED +error: + if (patternc != NULL) { + xmlFreePattern(patternc); + patternc = NULL; + } if (patstream != NULL) { xmlFreeStreamCtxt(patstream); patstream = NULL; From ef6e6012e291c0047b8c1300132761945f3e7574 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 01:13:49 +0200 Subject: [PATCH 438/504] xmllint: Fix parsing of maxmem option Fix corner cases like 'xmllint --encode --maxmem 123'. Also fixes --path without LIBXML_VALID_ENABLED. --- xmllint.c | 195 +++++++++++++++++++++++------------------------------- 1 file changed, 83 insertions(+), 112 deletions(-) diff --git a/xmllint.c b/xmllint.c index 317f24290..63b750af3 100644 --- a/xmllint.c +++ b/xmllint.c @@ -3149,6 +3149,48 @@ parseInteger(const char *ctxt, const char *str, return(val); } +static int +skipArgs(const char *arg) { + if ((!strcmp(arg, "-encode")) || + (!strcmp(arg, "--encode")) || + (!strcmp(arg, "-o")) || + (!strcmp(arg, "-output")) || + (!strcmp(arg, "--output")) || + (!strcmp(arg, "-path")) || + (!strcmp(arg, "--path")) || +#ifdef LIBXML_VALID_ENABLED + (!strcmp(arg, "-dtdvalid")) || + (!strcmp(arg, "--dtdvalid")) || + (!strcmp(arg, "-dtdvalidfpi")) || + (!strcmp(arg, "--dtdvalidfpi")) || +#endif /* LIBXML_VALID_ENABLED */ + (!strcmp(arg, "-relaxng")) || + (!strcmp(arg, "--relaxng")) || + (!strcmp(arg, "-maxmem")) || + (!strcmp(arg, "--maxmem")) || + (!strcmp(arg, "-pretty")) || + (!strcmp(arg, "--pretty")) || + (!strcmp(arg, "-schema")) || + (!strcmp(arg, "--schema")) || + (!strcmp(arg, "-schematron")) || + (!strcmp(arg, "--schematron")) || +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) + (!strcmp(arg, "-pattern")) || + (!strcmp(arg, "--pattern")) || +#endif +#ifdef LIBXML_XPATH_ENABLED + (!strcmp(arg, "-xpath")) || + (!strcmp(arg, "--xpath")) || +#endif + (!strcmp(arg, "-max-ampl")) || + (!strcmp(arg, "--max-ampl")) + ) { + return(1); + } + + return(0); +} + int main(int argc, char **argv) { int i, acount; @@ -3162,9 +3204,6 @@ main(int argc, char **argv) { /* xmlMemSetup must be called before initializing the parser. */ for (i = 1; i < argc ; i++) { - if (argv[i][0] != '-') - continue; - if ((!strcmp(argv[i], "-maxmem")) || (!strcmp(argv[i], "--maxmem"))) { i++; @@ -3174,7 +3213,9 @@ main(int argc, char **argv) { } errno = 0; maxmem = parseInteger("maxmem", argv[i], 0, INT_MAX); - } + } else if (argv[i][0] == '-') { + i += skipArgs(argv[i]); + } } if (maxmem != 0) xmlMemSetup(myFreeFunc, myMallocFunc, myReallocFunc, myStrdupFunc); @@ -3662,126 +3703,56 @@ main(int argc, char **argv) { } #endif /* LIBXML_READER_ENABLED && LIBXML_PATTERN_ENABLED */ for (i = 1; i < argc ; i++) { - if ((!strcmp(argv[i], "-encode")) || - (!strcmp(argv[i], "--encode"))) { - i++; - continue; - } else if ((!strcmp(argv[i], "-o")) || - (!strcmp(argv[i], "-output")) || - (!strcmp(argv[i], "--output"))) { - i++; - continue; - } -#ifdef LIBXML_VALID_ENABLED - if ((!strcmp(argv[i], "-dtdvalid")) || - (!strcmp(argv[i], "--dtdvalid"))) { - i++; - continue; - } - if ((!strcmp(argv[i], "-path")) || - (!strcmp(argv[i], "--path"))) { - i++; - continue; - } - if ((!strcmp(argv[i], "-dtdvalidfpi")) || - (!strcmp(argv[i], "--dtdvalidfpi"))) { - i++; - continue; - } -#endif /* LIBXML_VALID_ENABLED */ - if ((!strcmp(argv[i], "-relaxng")) || - (!strcmp(argv[i], "--relaxng"))) { - i++; - continue; - } - if ((!strcmp(argv[i], "-maxmem")) || - (!strcmp(argv[i], "--maxmem"))) { - i++; - continue; - } - if ((!strcmp(argv[i], "-pretty")) || - (!strcmp(argv[i], "--pretty"))) { - i++; - continue; - } - if ((!strcmp(argv[i], "-schema")) || - (!strcmp(argv[i], "--schema"))) { - i++; - continue; - } - if ((!strcmp(argv[i], "-schematron")) || - (!strcmp(argv[i], "--schematron"))) { - i++; - continue; - } -#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) - if ((!strcmp(argv[i], "-pattern")) || - (!strcmp(argv[i], "--pattern"))) { - i++; - continue; - } -#endif -#ifdef LIBXML_XPATH_ENABLED - if ((!strcmp(argv[i], "-xpath")) || - (!strcmp(argv[i], "--xpath"))) { - i++; - continue; - } -#endif - if ((!strcmp(argv[i], "-max-ampl")) || - (!strcmp(argv[i], "--max-ampl"))) { - i++; - continue; + if ((argv[i][0] == '-') && (strcmp(argv[i], "-") != 0)) { + i += skipArgs(argv[i]); + continue; } if ((timing) && (repeat)) startTimer(); - /* Remember file names. "-" means stdin. */ - if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) { - if (repeat) { - xmlParserCtxtPtr ctxt; + if (repeat) { + xmlParserCtxtPtr ctxt; - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - progresult = XMLLINT_ERR_MEM; - goto error; - } - if (maxAmpl > 0) - xmlCtxtSetMaxAmplification(ctxt, maxAmpl); + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + progresult = XMLLINT_ERR_MEM; + goto error; + } + if (maxAmpl > 0) + xmlCtxtSetMaxAmplification(ctxt, maxAmpl); - for (acount = 0;acount < repeat;acount++) { + for (acount = 0;acount < repeat;acount++) { #ifdef LIBXML_READER_ENABLED - if (stream != 0) { - streamFile(argv[i]); - } else { + if (stream != 0) { + streamFile(argv[i]); + } else { #endif /* LIBXML_READER_ENABLED */ - if (sax) { - testSAX(argv[i]); - } else { - parseAndPrintFile(argv[i], ctxt); - } + if (sax) { + testSAX(argv[i]); + } else { + parseAndPrintFile(argv[i], ctxt); + } #ifdef LIBXML_READER_ENABLED - } + } #endif /* LIBXML_READER_ENABLED */ - } + } - xmlFreeParserCtxt(ctxt); - } else { + xmlFreeParserCtxt(ctxt); + } else { #ifdef LIBXML_READER_ENABLED - if (stream != 0) - streamFile(argv[i]); - else + if (stream != 0) + streamFile(argv[i]); + else #endif /* LIBXML_READER_ENABLED */ - if (sax) { - testSAX(argv[i]); - } else { - parseAndPrintFile(argv[i], NULL); - } - } - files ++; - if ((timing) && (repeat)) { - endTimer("%d iterations", repeat); - } - } + if (sax) { + testSAX(argv[i]); + } else { + parseAndPrintFile(argv[i], NULL); + } + } + files ++; + if ((timing) && (repeat)) { + endTimer("%d iterations", repeat); + } } if (generate) parseAndPrintFile(NULL, NULL); From 3afaff7e8e75bbfe74187e5c8577865ff64ba3a3 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 11:16:01 +0200 Subject: [PATCH 439/504] xmllint: Check for NULL input in xmlHTMLValidityError `ctxt->input` can be NULL after commit 61b4c42f. --- xmllint.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xmllint.c b/xmllint.c index 63b750af3..26dda1b7c 100644 --- a/xmllint.c +++ b/xmllint.c @@ -672,10 +672,13 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...) buffer[0] = 0; input = ctxt->input; - if ((input->filename == NULL) && (ctxt->inputNr > 1)) - input = ctxt->inputTab[ctxt->inputNr - 2]; - xmlHTMLPrintFileInfo(input); + if (input != NULL) { + if ((input->filename == NULL) && (ctxt->inputNr > 1)) + input = ctxt->inputTab[ctxt->inputNr - 2]; + + xmlHTMLPrintFileInfo(input); + } fprintf(ERR_STREAM, "validity error: "); len = strlen(buffer); @@ -685,7 +688,8 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...) xmlHTMLEncodeSend(); fprintf(ERR_STREAM, "

    \n"); - xmlHTMLPrintFileContext(input); + if (input != NULL) + xmlHTMLPrintFileContext(input); xmlHTMLEncodeSend(); progresult = XMLLINT_ERR_VALID; } From 72e9267c32bd093b2c925eaebefc951c0cfde977 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 11:36:25 +0200 Subject: [PATCH 440/504] html: Fix memory leak after malloc failure --- HTMLtree.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/HTMLtree.c b/HTMLtree.c index acdde75d0..6e8baf488 100644 --- a/HTMLtree.c +++ b/HTMLtree.c @@ -513,7 +513,10 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc, */ handler = htmlFindOutputEncoder(encoding); buf = xmlOutputBufferCreateFile(out, handler); - if (buf == NULL) return(0); + if (buf == NULL) { + xmlCharEncCloseFunc(handler); + return(0); + } htmlNodeDumpFormatOutput(buf, doc, cur, NULL, format); @@ -563,8 +566,10 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) { encoding = (const char *) htmlGetMetaEncoding(cur); handler = htmlFindOutputEncoder(encoding); buf = xmlAllocOutputBufferInternal(handler); - if (buf == NULL) + if (buf == NULL) { + xmlCharEncCloseFunc(handler); return; + } htmlDocContentDumpFormatOutput(buf, cur, NULL, format); @@ -1029,7 +1034,10 @@ htmlDocDump(FILE *f, xmlDocPtr cur) { encoding = (const char *) htmlGetMetaEncoding(cur); handler = htmlFindOutputEncoder(encoding); buf = xmlOutputBufferCreateFile(f, handler); - if (buf == NULL) return(-1); + if (buf == NULL) { + xmlCharEncCloseFunc(handler); + return(-1); + } htmlDocContentDumpOutput(buf, cur, NULL); ret = xmlOutputBufferClose(buf); @@ -1060,7 +1068,10 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) { encoding = (const char *) htmlGetMetaEncoding(cur); handler = htmlFindOutputEncoder(encoding); buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression); - if (buf == NULL) return(0); + if (buf == NULL) { + xmlCharEncCloseFunc(handler); + return(0); + } htmlDocContentDumpOutput(buf, cur, NULL); @@ -1101,7 +1112,10 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur, * save the content to a temp buffer. */ buf = xmlOutputBufferCreateFilename(filename, handler, 0); - if (buf == NULL) return(0); + if (buf == NULL) { + xmlCharEncCloseFunc(handler); + return(0); + } htmlDocContentDumpFormatOutput(buf, cur, encoding, format); From 5bfaab77f6c1ce6efdcd4e8d0598924a9eb78850 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 6 May 2024 18:03:01 +0200 Subject: [PATCH 441/504] fuzz: Fix reader fuzzer --- fuzz/Makefile.am | 5 +++-- fuzz/testFuzzer.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am index 005d90b28..0db16ebe3 100644 --- a/fuzz/Makefile.am +++ b/fuzz/Makefile.am @@ -29,8 +29,9 @@ testFuzzer_SOURCES = testFuzzer.c fuzz.c .PHONY: corpus clean-corpus -corpus: seed/html.stamp seed/regexp.stamp seed/schema.stamp seed/uri.stamp \ - seed/valid.stamp seed/xinclude.stamp seed/xml.stamp seed/xpath.stamp +corpus: seed/html.stamp seed/reader.stamp seed/regexp.stamp seed/schema.stamp \ + seed/uri.stamp seed/valid.stamp seed/xinclude.stamp seed/xml.stamp \ + seed/xpath.stamp check-local: corpus ./testFuzzer$(EXEEXT) diff --git a/fuzz/testFuzzer.c b/fuzz/testFuzzer.c index 302964d70..0b6aa1da9 100644 --- a/fuzz/testFuzzer.c +++ b/fuzz/testFuzzer.c @@ -207,7 +207,7 @@ main(void) { ret = 1; #endif #ifdef HAVE_READER_FUZZER - if (testFuzzer(fuzzReaderInit, fuzzReader, "seed/xml/*") != 0) + if (testFuzzer(fuzzReaderInit, fuzzReader, "seed/reader/*") != 0) ret = 1; #endif #ifdef HAVE_REGEXP_FUZZER From 0bef170486223f5da754b2104773cc332a079ada Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 7 May 2024 12:15:24 +0200 Subject: [PATCH 442/504] c14n: Fix memory leak after malloc failure --- c14n.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/c14n.c b/c14n.c index cb1a6a062..964ac9989 100644 --- a/c14n.c +++ b/c14n.c @@ -2105,19 +2105,6 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes, return (ret); } - - -/* - * Macro used to grow the current buffer. - */ -#define growBufferReentrant() { \ - buffer_size *= 2; \ - buffer = (xmlChar *) \ - xmlRealloc(buffer, buffer_size); \ - if (buffer == NULL) \ - return(NULL); \ -} - /** * xmlC11NNormalizeString: * @input: the input string @@ -2153,9 +2140,16 @@ xmlC11NNormalizeString(const xmlChar * input, while (*cur != '\0') { if ((out - buffer) > (buffer_size - 10)) { + xmlChar *tmp; int indx = out - buffer; - growBufferReentrant(); + buffer_size *= 2; + tmp = xmlRealloc(buffer, buffer_size); + if (tmp == NULL) { + xmlFree(buffer); + return(NULL); + } + buffer = tmp; out = &buffer[indx]; } From f8ff4d86888ec122e1f75cd72deb959e8e6da718 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 7 May 2024 15:23:03 +0200 Subject: [PATCH 443/504] xmllint: Rework parsing Merge a few code paths, making options like --valid or --htmlout work with some other options. Improve error handling. --- xmllint.c | 352 +++++++++++++++++++++++++----------------------------- 1 file changed, 162 insertions(+), 190 deletions(-) diff --git a/xmllint.c b/xmllint.c index 26dda1b7c..55a069f64 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2134,35 +2134,45 @@ static void doXPathQuery(xmlDocPtr doc, const char *query) { * Tree Test processing * * * ************************************************************************/ -static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { - xmlDocPtr doc = NULL; -#ifdef LIBXML_TREE_ENABLED - xmlDocPtr tmp; -#endif /* LIBXML_TREE_ENABLED */ - - if ((timing) && (!repeat)) - startTimer(); +static xmlDocPtr +parseFile(const char *filename, xmlParserCtxtPtr rectxt) { + xmlParserCtxtPtr ctxt; + xmlDocPtr doc = NULL; #ifdef LIBXML_TREE_ENABLED - if (filename == NULL) { - if (generate) { - xmlNodePtr n; + if ((generate) && (filename == NULL)) { + xmlNodePtr n; - doc = xmlNewDoc(BAD_CAST "1.0"); - n = xmlNewDocNode(doc, NULL, BAD_CAST "info", NULL); - xmlNodeSetContent(n, BAD_CAST "abc"); - xmlDocSetRootElement(doc, n); - } + doc = xmlNewDoc(BAD_CAST "1.0"); + if (doc == NULL) { + progresult = XMLLINT_ERR_MEM; + return(NULL); + } + n = xmlNewDocNode(doc, NULL, BAD_CAST "info", NULL); + if (n == NULL) { + xmlFreeDoc(doc); + progresult = XMLLINT_ERR_MEM; + return(NULL); + } + if (xmlNodeSetContent(n, BAD_CAST "abc") < 0) { + xmlFreeNode(n); + xmlFreeDoc(doc); + progresult = XMLLINT_ERR_MEM; + return(NULL); + } + xmlDocSetRootElement(doc, n); + + return(doc); } #endif /* LIBXML_TREE_ENABLED */ + #ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_PUSH_ENABLED - else if ((html) && (push)) { + if ((html) && (push)) { FILE *f; int res; char chars[4096]; - htmlParserCtxtPtr ctxt; if ((filename[0] == '-') && (filename[1] == 0)) { f = stdin; @@ -2170,8 +2180,8 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { f = fopen(filename, "rb"); if (f == NULL) { fprintf(ERR_STREAM, "Can't open %s\n", filename); - progresult = XMLLINT_ERR_UNCLASS; - return; + progresult = XMLLINT_ERR_RDFILE; + return(NULL); } } @@ -2182,7 +2192,7 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { progresult = XMLLINT_ERR_MEM; if (f != stdin) fclose(f); - return; + return(NULL); } htmlCtxtUseOptions(ctxt, options); while ((res = fread(chars, 1, pushsize, f)) > 0) { @@ -2193,23 +2203,26 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { htmlFreeParserCtxt(ctxt); if (f != stdin) fclose(f); + + return(doc); } #endif /* LIBXML_PUSH_ENABLED */ + #ifdef HAVE_MMAP - else if ((html) && (memory)) { + if ((html) && (memory)) { int fd; struct stat info; const char *base; if (stat(filename, &info) < 0) - return; + return(NULL); if ((fd = open(filename, O_RDONLY)) < 0) - return; + return(NULL); base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (base == (void *) MAP_FAILED) { close(fd); fprintf(ERR_STREAM, "mmap failure for file %s\n", filename); progresult = XMLLINT_ERR_RDFILE; - return; + return(NULL); } doc = htmlReadMemory((char *) base, info.st_size, filename, @@ -2217,211 +2230,168 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { munmap((char *) base, info.st_size); close(fd); + + return(doc); } #endif - else if (html) { + + if (html) { if (strcmp(filename, "-") == 0) doc = htmlReadFd(STDIN_FILENO, "-", NULL, options); else doc = htmlReadFile(filename, NULL, options); + + return(doc); } #endif /* LIBXML_HTML_ENABLED */ - else { -#ifdef LIBXML_PUSH_ENABLED - /* - * build an XML tree from a string; - */ - if (push) { - FILE *f; - int ret; - int res; - char chars[4096]; - xmlParserCtxtPtr ctxt; - /* '-' Usually means stdin - */ - if ((filename[0] == '-') && (filename[1] == 0)) { - f = stdin; - } else { - f = fopen(filename, "rb"); - if (f == NULL) { - fprintf(ERR_STREAM, "Can't open %s\n", filename); - progresult = XMLLINT_ERR_UNCLASS; - return; - } - } +#ifdef LIBXML_PUSH_ENABLED + if (push) { + FILE *f; + int res; + char chars[4096]; - res = fread(chars, 1, 4, f); - ctxt = xmlCreatePushParserCtxt(NULL, NULL, - chars, res, filename); - if (ctxt == NULL) { - progresult = XMLLINT_ERR_MEM; - if (f != stdin) - fclose(f); - return; - } - xmlCtxtUseOptions(ctxt, options); - if (maxAmpl > 0) - xmlCtxtSetMaxAmplification(ctxt, maxAmpl); - while ((res = fread(chars, 1, pushsize, f)) > 0) { - xmlParseChunk(ctxt, chars, res, 0); - } - xmlParseChunk(ctxt, chars, 0, 1); - doc = ctxt->myDoc; - ret = ctxt->wellFormed; - xmlFreeParserCtxt(ctxt); - if ((!ret) && (!recovery)) { - xmlFreeDoc(doc); - doc = NULL; + if ((filename[0] == '-') && (filename[1] == 0)) { + f = stdin; + } else { + f = fopen(filename, "rb"); + if (f == NULL) { + fprintf(ERR_STREAM, "Can't open %s\n", filename); + progresult = XMLLINT_ERR_RDFILE; + return(NULL); } + } + + res = fread(chars, 1, 4, f); + ctxt = xmlCreatePushParserCtxt(NULL, NULL, + chars, res, filename); + if (ctxt == NULL) { + progresult = XMLLINT_ERR_MEM; if (f != stdin) fclose(f); - } else -#endif /* LIBXML_PUSH_ENABLED */ - if (testIO) { - if ((filename[0] == '-') && (filename[1] == 0)) { - doc = xmlReadFd(STDIN_FILENO, "-", NULL, options); - } else { - FILE *f; + return(NULL); + } + xmlCtxtUseOptions(ctxt, options); - f = fopen(filename, "rb"); - if (f != NULL) { - if (rectxt == NULL) - doc = xmlReadIO(myRead, myClose, f, filename, NULL, - options); - else - doc = xmlCtxtReadIO(rectxt, myRead, myClose, f, - filename, NULL, options); - } else - doc = NULL; - } - } else if (htmlout) { - xmlParserCtxtPtr ctxt; - - if (rectxt == NULL) { - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - progresult = XMLLINT_ERR_MEM; - return; - } - if (maxAmpl > 0) - xmlCtxtSetMaxAmplification(ctxt, maxAmpl); - } else { - ctxt = rectxt; - } + if (maxAmpl > 0) + xmlCtxtSetMaxAmplification(ctxt, maxAmpl); + if (htmlout) { ctxt->sax->error = xmlHTMLError; ctxt->sax->warning = xmlHTMLWarning; ctxt->vctxt.error = xmlHTMLValidityError; ctxt->vctxt.warning = xmlHTMLValidityWarning; + } - if (strcmp(filename, "-") == 0) - doc = xmlCtxtReadFd(ctxt, STDIN_FILENO, "-", NULL, options); - else - doc = xmlCtxtReadFile(ctxt, filename, NULL, options); + while ((res = fread(chars, 1, pushsize, f)) > 0) { + xmlParseChunk(ctxt, chars, res, 0); + } + xmlParseChunk(ctxt, chars, 0, 1); - if (rectxt == NULL) - xmlFreeParserCtxt(ctxt); -#ifdef HAVE_MMAP - } else if (memory) { - int fd; - struct stat info; - const char *base; - if (stat(filename, &info) < 0) - return; - if ((fd = open(filename, O_RDONLY)) < 0) - return; - base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; - if (base == (void *) MAP_FAILED) { - close(fd); - fprintf(ERR_STREAM, "mmap failure for file %s\n", filename); - progresult = XMLLINT_ERR_RDFILE; - return; - } + doc = ctxt->myDoc; + if (f != stdin) + fclose(f); + } else +#endif /* LIBXML_PUSH_ENABLED */ + { + if (rectxt == NULL) { + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + progresult = XMLLINT_ERR_MEM; + return(NULL); + } + } else { + ctxt = rectxt; + } - if (rectxt == NULL) { - xmlParserCtxtPtr ctxt; + if (maxAmpl > 0) + xmlCtxtSetMaxAmplification(ctxt, maxAmpl); - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - fprintf(ERR_STREAM, "out of memory\n"); - progresult = XMLLINT_ERR_MEM; - return; - } - if (maxAmpl > 0) - xmlCtxtSetMaxAmplification(ctxt, maxAmpl); - doc = xmlCtxtReadMemory(ctxt, base, info.st_size, - filename, NULL, options); - xmlFreeParserCtxt(ctxt); + if (htmlout) { + ctxt->sax->error = xmlHTMLError; + ctxt->sax->warning = xmlHTMLWarning; + ctxt->vctxt.error = xmlHTMLValidityError; + ctxt->vctxt.warning = xmlHTMLValidityWarning; + } + + if (testIO) { + FILE *f; + + if ((filename[0] == '-') && (filename[1] == 0)) { + f = stdin; } else { - doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size, - filename, NULL, options); + f = fopen(filename, "rb"); + if (f == NULL) { + fprintf(ERR_STREAM, "Can't open %s\n", filename); + progresult = XMLLINT_ERR_RDFILE; + goto error; + } } - munmap((char *) base, info.st_size); - close(fd); -#endif -#ifdef LIBXML_VALID_ENABLED - } else if (valid) { - xmlParserCtxtPtr ctxt = NULL; - - if (rectxt == NULL) { - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - progresult = XMLLINT_ERR_MEM; - return; - } - } else { - ctxt = rectxt; + doc = xmlCtxtReadIO(ctxt, myRead, myClose, f, filename, NULL, + options); +#ifdef HAVE_MMAP + } else if (memory) { + int fd; + struct stat info; + const char *base; + + if (stat(filename, &info) < 0) + goto error; + if ((fd = open(filename, O_RDONLY)) < 0) + goto error; + base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; + if (base == (void *) MAP_FAILED) { + close(fd); + fprintf(ERR_STREAM, "mmap failure for file %s\n", filename); + progresult = XMLLINT_ERR_RDFILE; + goto error; } - if (maxAmpl > 0) - xmlCtxtSetMaxAmplification(ctxt, maxAmpl); + doc = xmlCtxtReadMemory(ctxt, base, info.st_size, filename, NULL, + options); + munmap((char *) base, info.st_size); + close(fd); +#endif + } else { if (strcmp(filename, "-") == 0) doc = xmlCtxtReadFd(ctxt, STDIN_FILENO, "-", NULL, options); else doc = xmlCtxtReadFile(ctxt, filename, NULL, options); + } + } - if (ctxt->valid == 0) - progresult = XMLLINT_ERR_RDFILE; - if (rectxt == NULL) - xmlFreeParserCtxt(ctxt); + if (doc == NULL) { + if (ctxt->errNo == XML_ERR_NO_MEMORY) + progresult = XMLLINT_ERR_MEM; + else + progresult = XMLLINT_ERR_RDFILE; + } else { +#ifdef LIBXML_VALID_ENABLED + if ((valid) && (ctxt->valid == 0)) + progresult = XMLLINT_ERR_VALID; #endif /* LIBXML_VALID_ENABLED */ - } else { - if (rectxt != NULL) { - if (strcmp(filename, "-") == 0) - doc = xmlCtxtReadFd(rectxt, STDIN_FILENO, "-", NULL, - options); - else - doc = xmlCtxtReadFile(rectxt, filename, NULL, options); - } else { - xmlParserCtxtPtr ctxt; + } - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - fprintf(ERR_STREAM, "out of memory\n"); - progresult = XMLLINT_ERR_MEM; - return; - } - if (maxAmpl > 0) - xmlCtxtSetMaxAmplification(ctxt, maxAmpl); +error: + if (ctxt != rectxt) + xmlFreeParserCtxt(ctxt); - if (strcmp(filename, "-") == 0) - doc = xmlCtxtReadFd(ctxt, STDIN_FILENO, "-", NULL, - options); - else - doc = xmlCtxtReadFile(ctxt, filename, NULL, options); + return(doc); +} - xmlFreeParserCtxt(ctxt); - } - } - } +static void +parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { + xmlDocPtr doc; - /* - * If we don't have a document we might as well give up. Do we - * want an error message here? */ + if ((timing) && (!repeat)) + startTimer(); + + doc = parseFile(filename, rectxt); if (doc == NULL) { - progresult = XMLLINT_ERR_UNCLASS; + if (progresult == XMLLINT_RETURN_OK) + progresult = XMLLINT_ERR_UNCLASS; return; } @@ -2479,6 +2449,8 @@ static void parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { * test intermediate copy if needed. */ if (copy) { + xmlDocPtr tmp; + tmp = doc; if (timing) { startTimer(); From 3665d667f626715bd89d3f3e25d6746e741fdd8f Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 7 May 2024 16:53:43 +0200 Subject: [PATCH 444/504] xmllint: Clean up option handling Remove unnecessary globals and make some local. Remove unnecessary calls to xmlTextReaderSetParserProp. Remove unused "oldout" code. Fix skipArgs. --- xmllint.c | 240 +++++++++++++++++++----------------------------------- 1 file changed, 84 insertions(+), 156 deletions(-) diff --git a/xmllint.c b/xmllint.c index 55a069f64..05e37c34b 100644 --- a/xmllint.c +++ b/xmllint.c @@ -105,6 +105,7 @@ typedef enum { XMLLINT_ERR_XPATH = 10, /* XPath evaluation error */ XMLLINT_ERR_XPATH_EMPTY = 11 /* XPath result is empty */ } xmllintReturnCode; + #ifdef LIBXML_DEBUG_ENABLED static int shell = 0; static int debugent = 0; @@ -114,23 +115,18 @@ static int maxmem = 0; #ifdef LIBXML_TREE_ENABLED static int copy = 0; #endif /* LIBXML_TREE_ENABLED */ -static int recovery = 0; -static int noent = 0; -static int noenc = 0; -static int noblanks = 0; static int noout = 0; -static int nowrap = 0; -static int format = 0; #ifdef LIBXML_OUTPUT_ENABLED static const char *output = NULL; +static int format = 0; +static const char *encoding = NULL; static int compress = 0; -static int oldout = 0; #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_VALID_ENABLED -static int valid = 0; static int postvalid = 0; static const char *dtdvalid = NULL; static const char *dtdvalidfpi = NULL; +static int insert = 0; #endif #ifdef LIBXML_SCHEMAS_ENABLED static const char *relaxng = NULL; @@ -143,15 +139,11 @@ static const char *schematron = NULL; static xmlSchematronPtr wxschematron = NULL; #endif static int repeat = 0; -static int insert = 0; -#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) +#if defined(LIBXML_HTML_ENABLED) static int html = 0; static int xmlout = 0; #endif static int htmlout = 0; -#if defined(LIBXML_HTML_ENABLED) -static int nodefdtd = 0; -#endif #ifdef LIBXML_PUSH_ENABLED static int push = 0; static int pushsize = 4096; @@ -160,28 +152,20 @@ static int pushsize = 4096; static int memory = 0; #endif static int testIO = 0; -static const char *encoding = NULL; #ifdef LIBXML_XINCLUDE_ENABLED static int xinclude = 0; #endif -static int dtdattrs = 0; -static int loaddtd = 0; static xmllintReturnCode progresult = XMLLINT_RETURN_OK; static int quiet = 0; static int timing = 0; static int generate = 0; static int dropdtd = 0; -#ifdef LIBXML_CATALOG_ENABLED -static int catalogs = 0; -static int nocatalogs = 0; -#endif #ifdef LIBXML_C14N_ENABLED static int canonical = 0; static int canonical_11 = 0; static int exc_canonical = 0; #endif #ifdef LIBXML_READER_ENABLED -static int stream = 0; static int walker = 0; #ifdef LIBXML_PATTERN_ENABLED static const char *pattern = NULL; @@ -189,15 +173,10 @@ static xmlPatternPtr patternc = NULL; static xmlStreamCtxtPtr patstream = NULL; #endif #endif /* LIBXML_READER_ENABLED */ -#ifdef LIBXML_SAX1_ENABLED -static int sax1 = 0; -#endif /* LIBXML_SAX1_ENABLED */ #ifdef LIBXML_XPATH_ENABLED static const char *xpathquery = NULL; #endif static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES; -static int sax = 0; -static int oldxml10 = 0; static unsigned maxAmpl = 0; /************************************************************************ @@ -1600,7 +1579,7 @@ testSAX(const char *filename) { if (noout) { handler = emptySAXHandler; #ifdef LIBXML_SAX1_ENABLED - } else if (sax1) { + } else if (options & XML_PARSE_SAX1) { handler = debugSAXHandler; #endif } else { @@ -1821,13 +1800,6 @@ static void streamFile(const char *filename) { if (reader != NULL) { if (maxAmpl > 0) xmlTextReaderSetMaxAmplification(reader, maxAmpl); -#ifdef LIBXML_VALID_ENABLED - if (valid) - xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); - else -#endif /* LIBXML_VALID_ENABLED */ - if (loaddtd) - xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); #ifdef LIBXML_SCHEMAS_ENABLED if (relaxng != NULL) { if ((timing) && (!repeat)) { @@ -1884,7 +1856,7 @@ static void streamFile(const char *filename) { else #endif #ifdef LIBXML_VALID_ENABLED - if (valid) + if (options & XML_PARSE_DTDVALID) endTimer("Parsing and validating"); else #endif @@ -1892,7 +1864,7 @@ static void streamFile(const char *filename) { } #ifdef LIBXML_VALID_ENABLED - if (valid) { + if (options & XML_PARSE_DTDVALID) { if (xmlTextReaderIsValid(reader) != 1) { fprintf(ERR_STREAM, "Document %s does not validate\n", filename); @@ -2369,7 +2341,7 @@ parseFile(const char *filename, xmlParserCtxtPtr rectxt) { progresult = XMLLINT_ERR_RDFILE; } else { #ifdef LIBXML_VALID_ENABLED - if ((valid) && (ctxt->valid == 0)) + if ((options & XML_PARSE_DTDVALID) && (ctxt->valid == 0)) progresult = XMLLINT_ERR_VALID; #endif /* LIBXML_VALID_ENABLED */ } @@ -2510,8 +2482,6 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { #endif /* LIBXML_READER_ENABLED */ #ifdef LIBXML_OUTPUT_ENABLED if (noout == 0) { - int ret; - if (compress) xmlSetDocCompressMode(doc, 9); @@ -2640,46 +2610,6 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { #endif /* HAVE_MMAP */ if (compress) { xmlSaveFile(output ? output : "-", doc); - } else if (oldout) { - if (encoding != NULL) { - if (format == 1) { - ret = xmlSaveFormatFileEnc(output ? output : "-", doc, - encoding, 1); - } - else { - ret = xmlSaveFileEnc(output ? output : "-", doc, - encoding); - } - if (ret < 0) { - fprintf(ERR_STREAM, "failed save to %s\n", - output ? output : "-"); - progresult = XMLLINT_ERR_OUT; - } - } else if (format == 1) { - ret = xmlSaveFormatFile(output ? output : "-", doc, 1); - if (ret < 0) { - fprintf(ERR_STREAM, "failed save to %s\n", - output ? output : "-"); - progresult = XMLLINT_ERR_OUT; - } - } else { - FILE *out; - if (output == NULL) - out = stdout; - else { - out = fopen(output,"wb"); - } - if (out != NULL) { - if (xmlDocDump(out, doc) < 0) - progresult = XMLLINT_ERR_OUT; - - if (output != NULL) - fclose(out); - } else { - fprintf(ERR_STREAM, "failed to open %s\n", output); - progresult = XMLLINT_ERR_OUT; - } - } } else { xmlSaveCtxtPtr ctxt; int saveOpts = 0; @@ -3021,17 +2951,12 @@ static void usage(FILE *f, const char *name) { fprintf(f, "\t--postvalid : do a posteriori validation, i.e after parsing\n"); fprintf(f, "\t--dtdvalid URL : do a posteriori validation against a given DTD\n"); fprintf(f, "\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier\n"); + fprintf(f, "\t--insert : ad-hoc test for valid insertions\n"); #endif /* LIBXML_VALID_ENABLED */ fprintf(f, "\t--quiet : be quiet when succeeded\n"); fprintf(f, "\t--timing : print some timings\n"); - fprintf(f, "\t--output file or -o file: save to a given file\n"); fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n"); - fprintf(f, "\t--insert : ad-hoc test for valid insertions\n"); -#ifdef LIBXML_OUTPUT_ENABLED -#ifdef LIBXML_ZLIB_ENABLED - fprintf(f, "\t--compress : turn on gzip compression of output\n"); -#endif -#endif /* LIBXML_OUTPUT_ENABLED */ + fprintf(f, "\t--dropdtd : remove the DOCTYPE of the input docs\n"); #ifdef LIBXML_HTML_ENABLED fprintf(f, "\t--html : use the HTML parser\n"); fprintf(f, "\t--xmlout : force to use the XML serializer when using --html\n"); @@ -3049,13 +2974,16 @@ static void usage(FILE *f, const char *name) { fprintf(f, "\t--noblanks : drop (ignorable?) blanks spaces\n"); fprintf(f, "\t--nocdata : replace cdata section with text nodes\n"); #ifdef LIBXML_OUTPUT_ENABLED + fprintf(f, "\t--output file or -o file: save to a given file\n"); fprintf(f, "\t--format : reformat/reindent the output\n"); fprintf(f, "\t--encode encoding : output in the given encoding\n"); - fprintf(f, "\t--dropdtd : remove the DOCTYPE of the input docs\n"); fprintf(f, "\t--pretty STYLE : pretty-print in a particular style\n"); fprintf(f, "\t 0 Do not pretty print\n"); fprintf(f, "\t 1 Format the XML content, as --format\n"); fprintf(f, "\t 2 Add whitespace inside tags, preserving content\n"); +#ifdef LIBXML_ZLIB_ENABLED + fprintf(f, "\t--compress : turn on gzip compression of output\n"); +#endif #endif /* LIBXML_OUTPUT_ENABLED */ fprintf(f, "\t--c14n : save in W3C canonical format v1.0 (with comments)\n"); fprintf(f, "\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n"); @@ -3127,29 +3055,35 @@ parseInteger(const char *ctxt, const char *str, static int skipArgs(const char *arg) { - if ((!strcmp(arg, "-encode")) || - (!strcmp(arg, "--encode")) || + if ((!strcmp(arg, "-path")) || + (!strcmp(arg, "--path")) || + (!strcmp(arg, "-maxmem")) || + (!strcmp(arg, "--maxmem")) || +#ifdef LIBXML_OUTPUT_ENABLED (!strcmp(arg, "-o")) || (!strcmp(arg, "-output")) || (!strcmp(arg, "--output")) || - (!strcmp(arg, "-path")) || - (!strcmp(arg, "--path")) || + (!strcmp(arg, "-encode")) || + (!strcmp(arg, "--encode")) || + (!strcmp(arg, "-pretty")) || + (!strcmp(arg, "--pretty")) || +#endif #ifdef LIBXML_VALID_ENABLED (!strcmp(arg, "-dtdvalid")) || (!strcmp(arg, "--dtdvalid")) || (!strcmp(arg, "-dtdvalidfpi")) || (!strcmp(arg, "--dtdvalidfpi")) || -#endif /* LIBXML_VALID_ENABLED */ +#endif +#ifdef LIBXML_SCHEMAS_ENABLED (!strcmp(arg, "-relaxng")) || (!strcmp(arg, "--relaxng")) || - (!strcmp(arg, "-maxmem")) || - (!strcmp(arg, "--maxmem")) || - (!strcmp(arg, "-pretty")) || - (!strcmp(arg, "--pretty")) || (!strcmp(arg, "-schema")) || (!strcmp(arg, "--schema")) || +#endif +#ifdef LIBXML_SCHEMATRON_ENABLED (!strcmp(arg, "-schematron")) || (!strcmp(arg, "--schematron")) || +#endif #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) (!strcmp(arg, "-pattern")) || (!strcmp(arg, "--pattern")) || @@ -3172,6 +3106,15 @@ main(int argc, char **argv) { int i, acount; int files = 0; int version = 0; + int nowrap = 0; + int sax = 0; +#ifdef LIBXML_READER_ENABLED + int stream = 0; +#endif +#ifdef LIBXML_CATALOG_ENABLED + int catalogs = 0; + int nocatalogs = 0; +#endif if (argc <= 1) { usage(ERR_STREAM, argv[0]); @@ -3219,17 +3162,15 @@ main(int argc, char **argv) { #endif /* LIBXML_TREE_ENABLED */ if ((!strcmp(argv[i], "-recover")) || (!strcmp(argv[i], "--recover"))) { - recovery++; options |= XML_PARSE_RECOVER; } else if ((!strcmp(argv[i], "-huge")) || (!strcmp(argv[i], "--huge"))) { options |= XML_PARSE_HUGE; } else if ((!strcmp(argv[i], "-noent")) || (!strcmp(argv[i], "--noent"))) { - noent = 1; + options |= XML_PARSE_NOENT; } else if ((!strcmp(argv[i], "-noenc")) || (!strcmp(argv[i], "--noenc"))) { - noenc++; options |= XML_PARSE_IGNORE_ENC; } else if ((!strcmp(argv[i], "-nsclean")) || (!strcmp(argv[i], "--nsclean"))) { @@ -3247,14 +3188,6 @@ main(int argc, char **argv) { } else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) noout++; -#ifdef LIBXML_OUTPUT_ENABLED - else if ((!strcmp(argv[i], "-o")) || - (!strcmp(argv[i], "-output")) || - (!strcmp(argv[i], "--output"))) { - i++; - output = argv[i]; - } -#endif /* LIBXML_OUTPUT_ENABLED */ else if ((!strcmp(argv[i], "-htmlout")) || (!strcmp(argv[i], "--htmlout"))) htmlout++; @@ -3271,50 +3204,42 @@ main(int argc, char **argv) { xmlout++; } else if ((!strcmp(argv[i], "-nodefdtd")) || (!strcmp(argv[i], "--nodefdtd"))) { - nodefdtd++; options |= HTML_PARSE_NODEFDTD; } #endif /* LIBXML_HTML_ENABLED */ else if ((!strcmp(argv[i], "-loaddtd")) || (!strcmp(argv[i], "--loaddtd"))) { - loaddtd++; options |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-dtdattr")) || (!strcmp(argv[i], "--dtdattr"))) { - loaddtd++; - dtdattrs++; options |= XML_PARSE_DTDATTR; } #ifdef LIBXML_VALID_ENABLED else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) { - valid++; options |= XML_PARSE_DTDVALID; } else if ((!strcmp(argv[i], "-postvalid")) || (!strcmp(argv[i], "--postvalid"))) { postvalid++; - loaddtd++; options |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-dtdvalid")) || (!strcmp(argv[i], "--dtdvalid"))) { i++; dtdvalid = argv[i]; - loaddtd++; options |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-dtdvalidfpi")) || (!strcmp(argv[i], "--dtdvalidfpi"))) { i++; dtdvalidfpi = argv[i]; - loaddtd++; options |= XML_PARSE_DTDLOAD; } + else if ((!strcmp(argv[i], "-insert")) || + (!strcmp(argv[i], "--insert"))) + insert++; #endif /* LIBXML_VALID_ENABLED */ else if ((!strcmp(argv[i], "-dropdtd")) || (!strcmp(argv[i], "--dropdtd"))) dropdtd++; - else if ((!strcmp(argv[i], "-insert")) || - (!strcmp(argv[i], "--insert"))) - insert++; else if ((!strcmp(argv[i], "-quiet")) || (!strcmp(argv[i], "--quiet"))) quiet++; @@ -3368,14 +3293,6 @@ main(int argc, char **argv) { options |= XML_PARSE_NOBASEFIX; } #endif -#ifdef LIBXML_OUTPUT_ENABLED -#ifdef LIBXML_ZLIB_ENABLED - else if ((!strcmp(argv[i], "-compress")) || - (!strcmp(argv[i], "--compress"))) { - compress++; - } -#endif -#endif /* LIBXML_OUTPUT_ENABLED */ else if ((!strcmp(argv[i], "-nowarning")) || (!strcmp(argv[i], "--nowarning"))) { options |= XML_PARSE_NOWARNING; @@ -3418,37 +3335,48 @@ main(int argc, char **argv) { nocatalogs++; } #endif - else if ((!strcmp(argv[i], "-encode")) || - (!strcmp(argv[i], "--encode"))) { - i++; - encoding = argv[i]; - /* - * OK it's for testing purposes - */ - xmlAddEncodingAlias("UTF-8", "DVEnc"); - } else if ((!strcmp(argv[i], "-noblanks")) || (!strcmp(argv[i], "--noblanks"))) { - noblanks = 1; + options |= XML_PARSE_NOBLANKS; } else if ((!strcmp(argv[i], "-maxmem")) || (!strcmp(argv[i], "--maxmem"))) { i++; } +#ifdef LIBXML_OUTPUT_ENABLED + else if ((!strcmp(argv[i], "-o")) || + (!strcmp(argv[i], "-output")) || + (!strcmp(argv[i], "--output"))) { + i++; + output = argv[i]; + } else if ((!strcmp(argv[i], "-format")) || (!strcmp(argv[i], "--format"))) { -#ifdef LIBXML_OUTPUT_ENABLED format = 1; -#endif /* LIBXML_OUTPUT_ENABLED */ + options |= XML_PARSE_NOBLANKS; } + else if ((!strcmp(argv[i], "-encode")) || + (!strcmp(argv[i], "--encode"))) { + i++; + encoding = argv[i]; + /* + * OK it's for testing purposes + */ + xmlAddEncodingAlias("UTF-8", "DVEnc"); + } else if ((!strcmp(argv[i], "-pretty")) || (!strcmp(argv[i], "--pretty"))) { i++; -#ifdef LIBXML_OUTPUT_ENABLED if (argv[i] != NULL) format = atoi(argv[i]); -#endif /* LIBXML_OUTPUT_ENABLED */ } +#ifdef LIBXML_ZLIB_ENABLED + else if ((!strcmp(argv[i], "-compress")) || + (!strcmp(argv[i], "--compress"))) { + compress++; + } +#endif +#endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_READER_ENABLED else if ((!strcmp(argv[i], "-stream")) || (!strcmp(argv[i], "--stream"))) { @@ -3458,44 +3386,47 @@ main(int argc, char **argv) { (!strcmp(argv[i], "--walker"))) { walker++; noout++; + } #ifdef LIBXML_PATTERN_ENABLED - } else if ((!strcmp(argv[i], "-pattern")) || + else if ((!strcmp(argv[i], "-pattern")) || (!strcmp(argv[i], "--pattern"))) { i++; pattern = argv[i]; -#endif } +#endif #endif /* LIBXML_READER_ENABLED */ #ifdef LIBXML_SAX1_ENABLED else if ((!strcmp(argv[i], "-sax1")) || (!strcmp(argv[i], "--sax1"))) { - sax1++; options |= XML_PARSE_SAX1; } #endif /* LIBXML_SAX1_ENABLED */ else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax"))) { sax++; + } #ifdef LIBXML_SCHEMAS_ENABLED - } else if ((!strcmp(argv[i], "-relaxng")) || + else if ((!strcmp(argv[i], "-relaxng")) || (!strcmp(argv[i], "--relaxng"))) { i++; relaxng = argv[i]; - noent = 1; + options |= XML_PARSE_NOENT; } else if ((!strcmp(argv[i], "-schema")) || (!strcmp(argv[i], "--schema"))) { i++; schema = argv[i]; - noent = 1; + options |= XML_PARSE_NOENT; + } #endif #ifdef LIBXML_SCHEMATRON_ENABLED - } else if ((!strcmp(argv[i], "-schematron")) || + else if ((!strcmp(argv[i], "-schematron")) || (!strcmp(argv[i], "--schematron"))) { i++; schematron = argv[i]; - noent = 1; + options |= XML_PARSE_NOENT; + } #endif - } else if ((!strcmp(argv[i], "-nonet")) || + else if ((!strcmp(argv[i], "-nonet")) || (!strcmp(argv[i], "--nonet"))) { options |= XML_PARSE_NONET; xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader); @@ -3509,16 +3440,17 @@ main(int argc, char **argv) { (!strcmp(argv[i], "--path"))) { i++; parsePath(BAD_CAST argv[i]); + } #ifdef LIBXML_XPATH_ENABLED - } else if ((!strcmp(argv[i], "-xpath")) || + else if ((!strcmp(argv[i], "-xpath")) || (!strcmp(argv[i], "--xpath"))) { i++; noout++; xpathquery = argv[i]; + } #endif - } else if ((!strcmp(argv[i], "-oldxml10")) || + else if ((!strcmp(argv[i], "-oldxml10")) || (!strcmp(argv[i], "--oldxml10"))) { - oldxml10++; options |= XML_PARSE_OLD10; } else if ((!strcmp(argv[i], "-max-ampl")) || (!strcmp(argv[i], "--max-ampl"))) { @@ -3562,10 +3494,6 @@ main(int argc, char **argv) { defaultEntityLoader = xmlGetExternalEntityLoader(); xmlSetExternalEntityLoader(xmllintExternalEntityLoader); - if (noent != 0) - options |= XML_PARSE_NOENT; - if ((noblanks != 0) || (format == 1)) - options |= XML_PARSE_NOBLANKS; if ((htmlout) && (!nowrap)) { fprintf(ERR_STREAM, " Date: Wed, 8 May 2024 03:04:15 +0200 Subject: [PATCH 445/504] xmllint: Fix --pedantic option Regressed in 74c84a8c. --- xmllint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmllint.c b/xmllint.c index 05e37c34b..b2afbe969 100644 --- a/xmllint.c +++ b/xmllint.c @@ -3301,7 +3301,7 @@ main(int argc, char **argv) { else if ((!strcmp(argv[i], "-pedantic")) || (!strcmp(argv[i], "--pedantic"))) { options |= XML_PARSE_PEDANTIC; - options &= XML_PARSE_NOWARNING; + options &= ~XML_PARSE_NOWARNING; } #ifdef LIBXML_DEBUG_ENABLED else if ((!strcmp(argv[i], "-debugent")) || From 3ad7f81624572ebd5b9e6058c9f67d38207c10e2 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 8 May 2024 11:49:31 +0200 Subject: [PATCH 446/504] [CVE-2024-34459] Fix buffer overread with `xmllint --htmlout` Add a missing bounds check. Fixes #720. --- xmllint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmllint.c b/xmllint.c index b2afbe969..35c328578 100644 --- a/xmllint.c +++ b/xmllint.c @@ -543,7 +543,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) { len = strlen(buffer); snprintf(&buffer[len], sizeof(buffer) - len, "\n"); cur = input->cur; - while ((*cur == '\n') || (*cur == '\r')) + while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) cur--; n = 0; while ((cur != base) && (n++ < 80)) { From 3dea98eff9c11660dadbd1df6ab5c01da1f1b0e5 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 9 May 2024 21:10:28 +0200 Subject: [PATCH 447/504] xmllint: Don't free DTD with --dropdtd Entity references point to entities in the DTD, so only unlink the DTD and don't destroy it. --- xmllint.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/xmllint.c b/xmllint.c index 35c328578..51ade4bf9 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2371,17 +2371,13 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { endTimer("Parsing"); } - /* - * Remove DOCTYPE nodes - */ if (dropdtd) { xmlDtdPtr dtd; dtd = xmlGetIntSubset(doc); if (dtd != NULL) { xmlUnlinkNode((xmlNodePtr)dtd); - doc->intSubset = NULL; - xmlFreeDtd(dtd); + doc->intSubset = dtd; } } From 4fe116ebd3d8166ef41eec34fe2bd8a52fc9e8ac Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 10 May 2024 00:05:44 +0200 Subject: [PATCH 448/504] parser: Don't report error on invalid URI Only fragment identifiers are an error. This removes the last user of xmlErrMsg*. Now every error reported by the parser should result in one of ctxt->wellFormed, ctxt->nsWellFormed or ctxt->valid being set to zero. --- parser.c | 55 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/parser.c b/parser.c index f296f3280..1a235af3d 100644 --- a/parser.c +++ b/parser.c @@ -349,23 +349,6 @@ xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, val, NULL, NULL, 0, msg, val); } -/** - * xmlErrMsgStr: - * @ctxt: an XML parser context - * @error: the error number - * @msg: the error message - * @val: a string value - * - * Handle a non fatal parser error - */ -static void LIBXML_ATTR_FORMAT(3,0) -xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, - const char *msg, const xmlChar * val) -{ - xmlCtxtErr(ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_ERROR, - val, NULL, NULL, 0, msg, val); -} - /** * xmlNsErr: * @ctxt: an XML parser context @@ -5735,23 +5718,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL); } if (URI) { - xmlURIPtr uri; - - if (xmlParseURISafe((const char *) URI, &uri) < 0) { - xmlErrMemory(ctxt); - } else if (uri == NULL) { - /* - * This really ought to be a well formedness error - * but the XML Core WG decided otherwise c.f. issue - * E26 of the XML erratas. - */ - xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI, - "Invalid URI: %s\n", URI); - } else if (uri->fragment != NULL) { - /* - * Okay this is foolish to block those but not - * invalid URIs. - */ + if (xmlStrchr(URI, '#')) { xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL); } else { if ((ctxt->sax != NULL) && @@ -5761,7 +5728,6 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { XML_EXTERNAL_PARAMETER_ENTITY, literal, URI, NULL); } - xmlFreeURI(uri); } } } else { @@ -5803,26 +5769,9 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL); } if (URI) { - xmlURIPtr uri; - - if (xmlParseURISafe((const char *) URI, &uri) < 0) { - xmlErrMemory(ctxt); - } else if (uri == NULL) { - /* - * This really ought to be a well formedness error - * but the XML Core WG decided otherwise c.f. issue - * E26 of the XML erratas. - */ - xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI, - "Invalid URI: %s\n", URI); - } else if (uri->fragment != NULL) { - /* - * Okay this is foolish to block those but not - * invalid URIs. - */ + if (xmlStrchr(URI, '#')) { xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL); } - xmlFreeURI(uri); } if ((RAW != '>') && (SKIP_BLANKS_PE == 0)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, From 4ff2dccf9f3d653f29d27cfbae418931387d7a50 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 10 May 2024 02:04:52 +0200 Subject: [PATCH 449/504] SAX2: Warn if URI resolution failed --- SAX2.c | 25 ++++++++++++++++++------- parser.c | 2 ++ parserInternals.c | 4 +--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/SAX2.c b/SAX2.c index b8011fec5..267a5fb39 100644 --- a/SAX2.c +++ b/SAX2.c @@ -406,6 +406,7 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId xmlParserInputPtr ret = NULL; xmlChar *URI; const xmlChar *base = NULL; + int res; if (ctx == NULL) return(NULL); if (ctxt->input != NULL) @@ -416,8 +417,13 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long"); return(NULL); } - if (xmlBuildURISafe(systemId, base, &URI) < 0) { - xmlSAX2ErrMemory(ctxt); + res = xmlBuildURISafe(systemId, base, &URI); + if (URI == NULL) { + if (res < 0) + xmlSAX2ErrMemory(ctxt); + else + xmlWarnMsg(ctxt, XML_ERR_INVALID_URI, + "Can't resolve URI: %s\n", systemId); return(NULL); } if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) { @@ -568,11 +574,16 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, } } - if (xmlBuildURISafe(systemId, (const xmlChar *) base, &URI) < 0) { - xmlSAX2ErrMemory(ctxt); - return; - } - if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) { + res = xmlBuildURISafe(systemId, (const xmlChar *) base, &URI); + + if (URI == NULL) { + if (res < 0) { + xmlSAX2ErrMemory(ctxt); + } else { + xmlWarnMsg(ctxt, XML_ERR_INVALID_URI, + "Can't resolve URI: %s\n", systemId); + } + } else if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) { xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long"); xmlFree(URI); } else { diff --git a/parser.c b/parser.c index 1a235af3d..ea475951f 100644 --- a/parser.c +++ b/parser.c @@ -12168,6 +12168,8 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctxt, const xmlChar *URL, * @ID: the System ID for the entity to load * @lst: the return value for the set of parsed nodes * + * DEPRECATED: Use xmlParseCtxtExternalEntity. + * * Parse an external general entity * An external general parsed entity is well-formed if it matches the * production labeled extParsedEnt. diff --git a/parserInternals.c b/parserInternals.c index fa6911039..39d0007df 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -1844,9 +1844,7 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) { input = xmlLoadExternalEntity((char *) ent->URI, (char *) ent->ExternalID, ctxt); } else { - input = xmlNewInputMemory(ctxt, NULL, "", 0, NULL, - XML_INPUT_BUF_STATIC | - XML_INPUT_BUF_ZERO_TERMINATED); + return(NULL); } if (input == NULL) From a846719b9cd548d3e7e09475e3f33d8ef4101412 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 10 May 2024 11:21:11 +0200 Subject: [PATCH 450/504] pattern: Fix memory leak xmlCompileStepPattern --- pattern.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pattern.c b/pattern.c index 6cb489872..d03d37939 100644 --- a/pattern.c +++ b/pattern.c @@ -1242,6 +1242,8 @@ xmlCompilePathPattern(xmlPatParserContextPtr ctxt) { if (CUR == '@') { NEXT; xmlCompileAttributeTest(ctxt); + if (ctxt->error != 0) + goto error; SKIP_BLANKS; /* TODO: check for incompleteness */ if (CUR != 0) { From 16fb1028a2f2d1cab7f73348582c4ff1642d8c38 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 10 May 2024 12:00:12 +0200 Subject: [PATCH 451/504] reader: Fix error reporting with walker Abort earlier in xmlTextReaderRead if an error was raised. --- xmlreader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xmlreader.c b/xmlreader.c index 627d96ddb..3ad8d386c 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -1199,16 +1199,16 @@ xmlTextReaderRead(xmlTextReaderPtr reader) { xmlTextReaderState oldstate = XML_TEXTREADER_START; xmlNodePtr oldnode = NULL; - if (reader == NULL) return(-1); + if (reader->state == XML_TEXTREADER_ERROR) + return(-1); + reader->curnode = NULL; if (reader->doc != NULL) return(xmlTextReaderReadTree(reader)); if (reader->ctxt == NULL) return(-1); - if (reader->state == XML_TEXTREADER_ERROR) - return(-1); if (reader->mode == XML_TEXTREADER_MODE_INITIAL) { reader->mode = XML_TEXTREADER_MODE_INTERACTIVE; From b3cb41be8b83b546257cd3757fa6c8b4d34a4cc9 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 13 May 2024 12:18:08 +0200 Subject: [PATCH 452/504] fuzz: Add xmllint fuzzer --- fuzz/.gitignore | 1 + fuzz/Makefile.am | 27 +++++- fuzz/api.c | 2 +- fuzz/fuzz.c | 27 +----- fuzz/fuzz.h | 7 +- fuzz/genSeed.c | 41 +++++++-- fuzz/lint.c | 214 ++++++++++++++++++++++++++++++++++++++++++++++ fuzz/reader.c | 2 +- fuzz/schema.c | 2 +- fuzz/testFuzzer.c | 2 +- fuzz/valid.c | 2 +- fuzz/xinclude.c | 2 +- fuzz/xml.c | 2 +- xmllint.c | 98 ++++++++++++++++++++- 14 files changed, 380 insertions(+), 49 deletions(-) create mode 100644 fuzz/lint.c diff --git a/fuzz/.gitignore b/fuzz/.gitignore index 40d11bf9f..bf16acfdb 100644 --- a/fuzz/.gitignore +++ b/fuzz/.gitignore @@ -2,6 +2,7 @@ api corpus/ genSeed html +lint reader regexp schema diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am index 0db16ebe3..e85452bc9 100644 --- a/fuzz/Makefile.am +++ b/fuzz/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS = -Wno-syntax EXTRA_PROGRAMS = genSeed \ - api html reader regexp schema uri valid xinclude xml xpath + api html lint reader regexp schema uri valid xinclude \ + xml xpath check_PROGRAMS = testFuzzer EXTRA_DIST = html.dict regexp.dict schema.dict xml.dict xpath.dict \ static_seed/uri static_seed/regexp fuzz.h @@ -29,9 +30,9 @@ testFuzzer_SOURCES = testFuzzer.c fuzz.c .PHONY: corpus clean-corpus -corpus: seed/html.stamp seed/reader.stamp seed/regexp.stamp seed/schema.stamp \ - seed/uri.stamp seed/valid.stamp seed/xinclude.stamp seed/xml.stamp \ - seed/xpath.stamp +corpus: seed/html.stamp seed/lint.stamp seed/reader.stamp seed/regexp.stamp \ + seed/schema.stamp seed/uri.stamp seed/valid.stamp seed/xinclude.stamp \ + seed/xml.stamp seed/xpath.stamp check-local: corpus ./testFuzzer$(EXEEXT) @@ -135,6 +136,24 @@ fuzz-reader: reader$(EXEEXT) seed/reader.stamp $$XML_FUZZ_OPTIONS \ corpus/reader seed/reader +# xmllint fuzzer + +seed/lint.stamp: genSeed$(EXEEXT) + @mkdir -p seed/lint + ./genSeed$(EXEEXT) lint $(XML_SEED_CORPUS_SRC) + @touch seed/lint.stamp + +lint_SOURCES = lint.c fuzz.c +lint_LDFLAGS = -fsanitize=fuzzer + +fuzz-lint: lint$(EXEEXT) seed/lint.stamp + @mkdir -p corpus/lint + ./lint$(EXEEXT) \ + -dict=xml.dict \ + -max_len=$(XML_MAX_LEN) \ + $$XML_FUZZ_OPTIONS \ + corpus/lint seed/lint + # API fuzzer api_SOURCES = api.c fuzz.c diff --git a/fuzz/api.c b/fuzz/api.c index 3ac5c1fc0..80323ef45 100644 --- a/fuzz/api.c +++ b/fuzz/api.c @@ -964,7 +964,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/fuzz.c b/fuzz/fuzz.c index 3d0dbe1e2..557343ab1 100644 --- a/fuzz/fuzz.c +++ b/fuzz/fuzz.c @@ -391,10 +391,8 @@ xmlFuzzMainEntity(size_t *size) { * * The entity loader for fuzz data. */ -xmlParserInputPtr -xmlFuzzEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED, - xmlParserCtxtPtr ctxt) { - xmlParserInputPtr input; +xmlParserInputBufferPtr +xmlFuzzEntityLoader(const char *URL, xmlCharEncoding enc) { xmlFuzzEntityInfo *entity; if (URL == NULL) @@ -403,26 +401,7 @@ xmlFuzzEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED, if (entity == NULL) return(NULL); - input = xmlNewInputStream(ctxt); - if (input == NULL) - return(NULL); - input->filename = (char *) xmlCharStrdup(URL); - if (input->filename == NULL) { - xmlCtxtErrMemory(ctxt); - xmlFreeInputStream(input); - return(NULL); - } - input->buf = xmlParserInputBufferCreateMem(entity->data, entity->size, - XML_CHAR_ENCODING_NONE); - if (input->buf == NULL) { - xmlCtxtErrMemory(ctxt); - xmlFreeInputStream(input); - return(NULL); - } - input->base = input->cur = xmlBufContent(input->buf->buffer); - input->end = input->base + xmlBufUse(input->buf->buffer); - - return input; + return(xmlParserInputBufferCreateMem(entity->data, entity->size, enc)); } char * diff --git a/fuzz/fuzz.h b/fuzz/fuzz.h index c92366887..592f44134 100644 --- a/fuzz/fuzz.h +++ b/fuzz/fuzz.h @@ -18,6 +18,9 @@ extern "C" { #if defined(LIBXML_HTML_ENABLED) #define HAVE_HTML_FUZZER #endif +#if 1 + #define HAVE_LINT_FUZZER +#endif #if defined(LIBXML_READER_ENABLED) #define HAVE_READER_FUZZER #endif @@ -101,8 +104,8 @@ xmlFuzzMainUrl(void); const char * xmlFuzzMainEntity(size_t *size); -xmlParserInputPtr -xmlFuzzEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt); +xmlParserInputBufferPtr +xmlFuzzEntityLoader(const char *URL, xmlCharEncoding enc); char * xmlSlurpFile(const char *path, size_t *size); diff --git a/fuzz/genSeed.c b/fuzz/genSeed.c index 38e2f7500..334527eb9 100644 --- a/fuzz/genSeed.c +++ b/fuzz/genSeed.c @@ -28,6 +28,7 @@ #define EXPR_SIZE 4500 #define FLAG_READER (1 << 0) +#define FLAG_LINT (1 << 1) typedef int (*fileFunc)(const char *base, FILE *out); @@ -115,14 +116,32 @@ processXml(const char *docFile, FILE *out) { int opts = XML_PARSE_NOENT | XML_PARSE_DTDLOAD; xmlDocPtr doc; - /* Parser options. */ - xmlFuzzWriteInt(out, opts, 4); - /* Max allocations. */ - xmlFuzzWriteInt(out, 0, 4); - - if (globalData.flags & FLAG_READER) { - /* Initial reader program with a couple of OP_READs */ - xmlFuzzWriteString(out, "\x01\x01\x01\x01\x01\x01\x01\x01"); + if (globalData.flags & FLAG_LINT) { + /* Switches */ + xmlFuzzWriteInt(out, 0, 4); + xmlFuzzWriteInt(out, 0, 4); + /* maxmem */ + xmlFuzzWriteInt(out, 0, 4); + /* max-ampl */ + xmlFuzzWriteInt(out, 0, 1); + /* pretty */ + xmlFuzzWriteInt(out, 0, 1); + /* encode */ + xmlFuzzWriteString(out, ""); + /* pattern */ + xmlFuzzWriteString(out, ""); + /* xpath */ + xmlFuzzWriteString(out, ""); + } else { + /* Parser options. */ + xmlFuzzWriteInt(out, opts, 4); + /* Max allocations. */ + xmlFuzzWriteInt(out, 0, 4); + + if (globalData.flags & FLAG_READER) { + /* Initial reader program with a couple of OP_READs */ + xmlFuzzWriteString(out, "\x01\x01\x01\x01\x01\x01\x01\x01"); + } } fuzzRecorderInit(out); @@ -423,6 +442,12 @@ main(int argc, const char **argv) { #ifdef HAVE_HTML_FUZZER processArg = processPattern; globalData.processFile = processHtml; +#endif + } else if (strcmp(fuzzer, "lint") == 0) { +#ifdef HAVE_LINT_FUZZER + processArg = processPattern; + globalData.flags |= FLAG_LINT; + globalData.processFile = processXml; #endif } else if (strcmp(fuzzer, "reader") == 0) { #ifdef HAVE_READER_FUZZER diff --git a/fuzz/lint.c b/fuzz/lint.c new file mode 100644 index 000000000..8a92829f1 --- /dev/null +++ b/fuzz/lint.c @@ -0,0 +1,214 @@ +/* + * xml.c: a libFuzzer target to test several XML parser interfaces. + * + * See Copyright for the status of this software. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "fuzz.h" + +#define XMLLINT_FUZZ +#include "../xmllint.c" + +static const char *const switches[] = { + "--auto", + "--c14n", + "--c14n11", + "--compress", + "--copy", + "--debug", + "--debugent", + "--dropdtd", + "--dtdattr", + "--exc-c14n", + "--format", + "--htmlout", + "--huge", + "--insert", + "--loaddtd", + "--load-trace", + "--memory", + "--noblanks", + "--nocdata", + "--nocompact", + "--nodefdtd", + "--nodict", + "--noenc", + "--noent", + "--nofixup-base-uris", + "--nonet", + "--noout", + "--nowarning", + "--nowrap", + "--noxincludenode", + "--nsclean", + "--oldxml10", + "--pedantic", + "--postvalid", + "--push", + "--pushsmall", + "--quiet", + "--recover", + "--sax1", + "--testIO", + "--timing", + "--valid", + "--version", + "--walker", + "--xinclude", + "--xmlout" +}; +static const size_t numSwitches = sizeof(switches) / sizeof(switches[0]); + +struct { + const char **argv; + size_t argi; +} vars; + +static void +pushArg(const char *str) { + vars.argv[vars.argi++] = str; +} + +int +LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, + char ***argv ATTRIBUTE_UNUSED) { + int fd; + + /* Redirect stdout to /dev/null */ + fd = open("/dev/null", O_WRONLY); + if (fd == -1) { + perror("/dev/null"); + abort(); + } + if (dup2(fd, STDOUT_FILENO) == -1) { + perror("dup2"); + abort(); + } + close(fd); + + return 0; +} + +int +LLVMFuzzerTestOneInput(const char *data, size_t size) { + char maxmemBuf[20]; + char maxAmplBuf[20]; + char prettyBuf[20]; + const char *sval, *docBuffer, *docUrl; + size_t ssize, docSize, i; + unsigned uval; + int ival; + + vars.argv = malloc((numSwitches + 5 + 6 * 2) * sizeof(vars.argv[0])); + vars.argi = 0; + pushArg("xmllint"), + pushArg("--nocatalogs"); + + xmlFuzzDataInit(data, size); + + for (i = 0; i < numSwitches; i++) { + if (i % 32 == 0) + uval = xmlFuzzReadInt(4); + if ((uval & 1) && (switches[i] != NULL)) + pushArg(switches[i]); + uval >>= 1; + } + + /* + * Use four main parsing modes with equal probability + */ + switch (uval & 3) { + case 0: + /* XML parser */ + break; + case 1: + /* HTML parser */ + pushArg("--html"); + break; + case 2: + /* XML reader */ + pushArg("--stream"); + break; + case 3: + /* SAX parser */ + pushArg("--sax"); + break; + } + + uval = xmlFuzzReadInt(4); + if (uval > 0) { + if (size <= (INT_MAX - 2000) / 20) + uval %= size * 20 + 2000; + else + uval %= INT_MAX; + snprintf(maxmemBuf, 20, "%u", uval); + pushArg("--maxmem"); + pushArg(maxmemBuf); + } + + ival = xmlFuzzReadInt(1); + if (ival >= 1 && ival <= 5) { + snprintf(maxAmplBuf, 20, "%d", ival); + pushArg("--max-ampl"); + pushArg(maxAmplBuf); + } + + ival = xmlFuzzReadInt(1); + if (ival != 0) { + snprintf(prettyBuf, 20, "%d", ival - 128); + pushArg("--pretty"); + pushArg(prettyBuf); + } + + sval = xmlFuzzReadString(&ssize); + if (ssize > 0) { + pushArg("--encode"); + pushArg(sval); + } + + sval = xmlFuzzReadString(&ssize); + if (ssize > 0) { + pushArg("--pattern"); + pushArg(sval); + } + + sval = xmlFuzzReadString(&ssize); + if (ssize > 0) { + pushArg("--xpath"); + pushArg(sval); + } + + xmlFuzzReadEntities(); + docBuffer = xmlFuzzMainEntity(&docSize); + docUrl = xmlFuzzMainUrl(); + if (docBuffer == NULL || docUrl[0] == '-') + goto exit; + pushArg(docUrl); + + pushArg(NULL); + + xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); +#ifdef LIBXML_CATALOG_ENABLED + xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); +#endif + + xmllintMain(vars.argi - 1, vars.argv); + + xmlMemSetup(free, malloc, realloc, xmlMemStrdup); + +exit: + xmlFuzzDataCleanup(); + free(vars.argv); + return(0); +} diff --git a/fuzz/reader.c b/fuzz/reader.c index 5721d356a..7935d238c 100644 --- a/fuzz/reader.c +++ b/fuzz/reader.c @@ -102,7 +102,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/schema.c b/fuzz/schema.c index 611deeca2..a9111fca1 100644 --- a/fuzz/schema.c +++ b/fuzz/schema.c @@ -18,7 +18,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/testFuzzer.c b/fuzz/testFuzzer.c index 0b6aa1da9..a0543e5b1 100644 --- a/fuzz/testFuzzer.c +++ b/fuzz/testFuzzer.c @@ -162,7 +162,7 @@ testEntityLoader(void) { xmlDocPtr doc; int ret = 0; - xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); xmlFuzzDataInit(data, sizeof(data) - 1); xmlFuzzReadEntities(); diff --git a/fuzz/valid.c b/fuzz/valid.c index 67b2fb246..df896df0a 100644 --- a/fuzz/valid.c +++ b/fuzz/valid.c @@ -20,7 +20,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/xinclude.c b/fuzz/xinclude.c index e38a69e08..53bef1ccc 100644 --- a/fuzz/xinclude.c +++ b/fuzz/xinclude.c @@ -21,7 +21,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/xml.c b/fuzz/xml.c index 31ab21022..ef017c86e 100644 --- a/fuzz/xml.c +++ b/fuzz/xml.c @@ -21,7 +21,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlSetExternalEntityLoader(xmlFuzzEntityLoader); + xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); return 0; } diff --git a/xmllint.c b/xmllint.c index 51ade4bf9..4bdf54390 100644 --- a/xmllint.c +++ b/xmllint.c @@ -81,7 +81,11 @@ #include #endif -#define ERR_STREAM stderr +#ifdef XMLLINT_FUZZ + #define ERR_STREAM stdout +#else + #define ERR_STREAM stderr +#endif #ifndef XML_XML_DEFAULT_CATALOG #define XML_XML_DEFAULT_CATALOG "file://" SYSCONFDIR "/xml/catalog" @@ -302,6 +306,7 @@ xmllintExternalEntityLoader(const char *URL, const char *ID, } return(NULL); } + /************************************************************************ * * * Memory allocation consumption debugging * @@ -356,7 +361,7 @@ myStrdupFunc(const char *str) if (ret != NULL) { if (xmlMemUsed() > maxmem) { OOM(); - xmlFree(ret); + xmlMemFree(ret); return (NULL); } } @@ -3097,8 +3102,8 @@ skipArgs(const char *arg) { return(0); } -int -main(int argc, char **argv) { +static int +xmllintMain(int argc, const char **argv) { int i, acount; int files = 0; int version = 0; @@ -3112,6 +3117,82 @@ main(int argc, char **argv) { int nocatalogs = 0; #endif +#ifdef XMLLINT_FUZZ +#ifdef LIBXML_DEBUG_ENABLED + shell = 0; + debugent = 0; +#endif + debug = 0; + maxmem = 0; +#ifdef LIBXML_TREE_ENABLED + copy = 0; +#endif /* LIBXML_TREE_ENABLED */ + noout = 0; +#ifdef LIBXML_OUTPUT_ENABLED + format = 0; + output = NULL; + compress = 0; +#endif /* LIBXML_OUTPUT_ENABLED */ +#ifdef LIBXML_VALID_ENABLED + postvalid = 0; + dtdvalid = NULL; + dtdvalidfpi = NULL; + insert = 0; +#endif +#ifdef LIBXML_SCHEMAS_ENABLED + relaxng = NULL; + relaxngschemas = NULL; + schema = NULL; + wxschemas = NULL; +#endif +#ifdef LIBXML_SCHEMATRON_ENABLED + schematron = NULL; + wxschematron = NULL; +#endif + repeat = 0; +#if defined(LIBXML_HTML_ENABLED) + html = 0; + xmlout = 0; +#endif + htmlout = 0; +#ifdef LIBXML_PUSH_ENABLED + push = 0; + pushsize = 4096; +#endif /* LIBXML_PUSH_ENABLED */ +#ifdef HAVE_MMAP + memory = 0; +#endif + testIO = 0; + encoding = NULL; +#ifdef LIBXML_XINCLUDE_ENABLED + xinclude = 0; +#endif + progresult = XMLLINT_RETURN_OK; + quiet = 0; + timing = 0; + generate = 0; + dropdtd = 0; +#ifdef LIBXML_C14N_ENABLED + canonical = 0; + canonical_11 = 0; + exc_canonical = 0; +#endif +#ifdef LIBXML_READER_ENABLED + walker = 0; +#ifdef LIBXML_PATTERN_ENABLED + pattern = NULL; + patternc = NULL; + patstream = NULL; +#endif +#endif /* LIBXML_READER_ENABLED */ +#ifdef LIBXML_XPATH_ENABLED + xpathquery = NULL; +#endif + options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES; + maxAmpl = 0; + defaultEntityLoader = NULL; +#endif /* XMLLINT_FUZZ */ + if (argc <= 1) { usage(ERR_STREAM, argv[0]); return(XMLLINT_ERR_UNCLASS); @@ -3682,8 +3763,17 @@ main(int argc, char **argv) { goto error; error: + if (defaultEntityLoader != NULL) + xmlSetExternalEntityLoader(defaultEntityLoader); xmlCleanupParser(); return(progresult); } +#ifndef XMLLINT_FUZZ +int +main(int argc, char **argv) { + return(xmllintMain(argc, (const char **) argv)); +} +#endif + From 609d2666fa61b26a8627e9a0051fa9f20048180a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 1 May 2024 23:46:46 +0200 Subject: [PATCH 453/504] Stop defining _REENTRANT This macro is obsolete, see `man feature_test_macros`. --- CMakeLists.txt | 1 - Makefile.am | 2 -- configure.ac | 8 +------- meson.build | 5 ----- win32/Makefile.bcb | 4 ++-- win32/Makefile.mingw | 6 ------ win32/Makefile.msvc | 6 ------ 7 files changed, 3 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efff2ccce..00ccc3694 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -325,7 +325,6 @@ add_library(LibXml2::LibXml2 ALIAS LibXml2) target_compile_definitions(LibXml2 PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") if(LIBXML2_WITH_THREADS) - target_compile_definitions(LibXml2 PRIVATE _REENTRANT) if(NOT WIN32) check_include_files(pthread.h HAVE_PTHREAD_H) endif() diff --git a/Makefile.am b/Makefile.am index 9eff073e3..4cb9a5cc9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -118,7 +118,6 @@ m4datadir = $(datadir)/aclocal dist_m4data_DATA = libxml.m4 runtest_SOURCES=runtest.c -runtest_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) runtest_DEPENDENCIES = $(DEPS) runtest_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS) @@ -157,7 +156,6 @@ xmlcatalog_DEPENDENCIES = $(DEPS) xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS) testThreads_SOURCES = testThreads.c -testThreads_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) testThreads_DEPENDENCIES = $(DEPS) testThreads_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS) diff --git a/configure.ac b/configure.ac index fc0a9b3db..65dea7dc8 100644 --- a/configure.ac +++ b/configure.ac @@ -795,7 +795,6 @@ dnl THREAD_LIBS="" BASE_THREAD_LIBS="" WITH_THREADS=0 -THREAD_CFLAGS="" WITH_THREAD_ALLOC=0 if test "$with_threads" = "no" ; then @@ -829,10 +828,6 @@ else fi ;; esac - - if test "$WITH_THREADS" = "1" ; then - THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT" - fi fi if test "$with_thread_alloc" = "yes" && test "$WITH_THREADS" = "1" ; then WITH_THREAD_ALLOC=1 @@ -841,7 +836,6 @@ fi AC_SUBST(THREAD_LIBS) AC_SUBST(BASE_THREAD_LIBS) AC_SUBST(WITH_THREADS) -AC_SUBST(THREAD_CFLAGS) AC_SUBST(WITH_THREAD_ALLOC) dnl @@ -1115,7 +1109,7 @@ XML_LIBTOOLLIBS="libxml2.la" NON_PC_LIBS="${THREAD_LIBS} ${ICONV_LIBS} ${LIBM} ${NET_LIBS} ${CRYPTO_LIBS}" XML_PC_LIBS="${XML_PC_LIBS} ${NON_PC_LIBS}" XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${NON_PC_LIBS}" -XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${THREAD_CFLAGS} ${ICONV_CFLAGS}" +XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${ICONV_CFLAGS}" dnl When static-only: dnl * Duplicate xml-config static --libs into --dynamic. diff --git a/meson.build b/meson.build index 450d80bb7..13d966b33 100644 --- a/meson.build +++ b/meson.build @@ -441,11 +441,6 @@ if want_threads == true endif endif -if want_threads == true - thread_cflags = '-D_REENTRANT' - libxml2_cflags += thread_cflags -endif - want_thread_alloc = ( (want_threads == true and want_threads == true) ? true : false ) diff --git a/win32/Makefile.bcb b/win32/Makefile.bcb index 13e02395a..49ea0afd0 100644 --- a/win32/Makefile.bcb +++ b/win32/Makefile.bcb @@ -44,7 +44,7 @@ UTILS_INTDIR = int.utils.bcb CPP = cpp32.exe -P- CPPFLAGS = -I"$(XML_SRCDIR)\include" -DNOLIBTOOL !if "$(WITH_THREADS)" != "no" -CPPFLAGS = $(CPPFLAGS) -D_REENTRANT -D__MT__ +CPPFLAGS = $(CPPFLAGS) -D__MT__ !endif # The compiler and its options. @@ -52,7 +52,7 @@ CC = bcc32.exe CFLAGS = -q -D_NO_VCL -D_WINDOWS -D_MBCS -DEILSEQ=2 -DNOLIBTOOL -w- CFLAGS = $(CFLAGS) -I"$(XML_SRCDIR)" -I"$(XML_SRCDIR)\include" -I"$(INCPREFIX)" -I"$(INCLUDE)" !if "$(WITH_THREADS)" != "no" -CFLAGS = $(CFLAGS) -D_REENTRANT -tWM +CFLAGS = $(CFLAGS) -tWM !endif !if "$(DYNRUNTIME)" == "1" CFLAGS = $(CFLAGS) -tWR diff --git a/win32/Makefile.mingw b/win32/Makefile.mingw index 620dc1d3a..087583fa7 100644 --- a/win32/Makefile.mingw +++ b/win32/Makefile.mingw @@ -34,17 +34,11 @@ UTILS_INTDIR = int.utils.mingw # The preprocessor and its options. CPP = gcc.exe -E CPPFLAGS += -I$(XML_SRCDIR)/include -DNOLIBTOOL -ifeq ($(WITH_THREADS),1) -CPPFLAGS += -D_REENTRANT -endif # The compiler and its options. CC = gcc.exe CFLAGS += -D_WINDOWS -D_MBCS -DNOLIBTOOL CFLAGS += -I$(XML_SRCDIR) -I$(XML_SRCDIR)/include -I$(INCPREFIX) $(INCLUDE) -ifneq ($(WITH_THREADS),no) -CFLAGS += -D_REENTRANT -endif ifeq ($(WITH_THREADS),ctls) CFLAGS += "-DXML_THREAD_LOCAL=__declspec(thread)" endif diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc index bc8ddd0b0..ce877a5e6 100644 --- a/win32/Makefile.msvc +++ b/win32/Makefile.msvc @@ -37,17 +37,11 @@ UTILS_INTDIR = int.utils.msvc # The preprocessor and its options. CPP = cl.exe /EP CPPFLAGS = /nologo /I$(XML_SRCDIR)\include /D "NOLIBTOOL" -!if "$(WITH_THREADS)" != "no" -CPPFLAGS = $(CPPFLAGS) /D "_REENTRANT" -!endif # The compiler and its options. CC = cl.exe CFLAGS = /nologo /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W3 /wd4244 /wd4267 $(CRUNTIME) CFLAGS = $(CFLAGS) /I$(XML_SRCDIR) /I$(XML_SRCDIR)\include /I$(INCPREFIX) -!if "$(WITH_THREADS)" != "no" -CFLAGS = $(CFLAGS) /D "_REENTRANT" -!endif !if "$(WITH_THREADS)" == "ctls" CFLAGS = $(CFLAGS) /D "XML_THREAD_LOCAL=__declspec(thread)" !else if "$(WITH_THREADS)" == "posix" From 0651ad667c8c7a2505d4cbda90ae5be346e8a35e Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 5 May 2024 20:20:22 +0200 Subject: [PATCH 454/504] valid: Report malloc failure after xmlRegExecPushString --- valid.c | 9 +++++++-- xmlregexp.c | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/valid.c b/valid.c index 897a368dd..a7c4e4a17 100644 --- a/valid.c +++ b/valid.c @@ -5171,6 +5171,8 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child, } } ret = xmlRegExecPushString(exec, NULL, NULL); + if (ret == XML_REGEXP_OUT_OF_MEMORY) + xmlVErrMemory(ctxt); fail: xmlRegFreeExecCtxt(exec); } @@ -5768,8 +5770,11 @@ xmlValidatePopElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED, if (state->exec != NULL) { ret = xmlRegExecPushString(state->exec, NULL, NULL); if (ret <= 0) { - xmlErrValidNode(ctxt, state->node, - XML_DTD_CONTENT_MODEL, + if (ret == XML_REGEXP_OUT_OF_MEMORY) + xmlVErrMemory(ctxt); + else + xmlErrValidNode(ctxt, state->node, + XML_DTD_CONTENT_MODEL, "Element %s content does not follow the DTD, Expecting more children\n", state->node->name, NULL,NULL); ret = 0; diff --git a/xmlregexp.c b/xmlregexp.c index 9e3b2548e..31e3d1a62 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -3500,7 +3500,7 @@ xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) { xmlFree(exec); } -static void +static int xmlRegExecSetErrString(xmlRegExecCtxtPtr exec, const xmlChar *value) { if (exec->errString != NULL) xmlFree(exec->errString); @@ -3508,9 +3508,12 @@ xmlRegExecSetErrString(xmlRegExecCtxtPtr exec, const xmlChar *value) { exec->errString = NULL; } else { exec->errString = xmlStrdup(value); - if (exec->errString == NULL) + if (exec->errString == NULL) { exec->status = XML_REGEXP_OUT_OF_MEMORY; + return(-1); + } } + return(0); } static void @@ -3917,7 +3920,8 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value, * entering a sink state, save the current state as error * state. */ - xmlRegExecSetErrString(exec, value); + if (xmlRegExecSetErrString(exec, value) < 0) + break; exec->errState = exec->state; memcpy(exec->errCounts, exec->counts, exec->comp->nbCounters * sizeof(int)); @@ -3954,7 +3958,8 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value, if ((progress) && (exec->state != NULL) && (exec->state->type != XML_REGEXP_SINK_STATE)) { progress = 0; - xmlRegExecSetErrString(exec, value); + if (xmlRegExecSetErrString(exec, value) < 0) + break; exec->errState = exec->state; if (exec->comp->nbCounters) memcpy(exec->errCounts, exec->counts, From b117a912b6e46a03b62828b9fd6da6fbc2e4341d Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 13 May 2024 13:42:43 +0200 Subject: [PATCH 455/504] fuzz: Enable xmllint fuzzer on OSS-Fuzz --- fuzz/oss-fuzz-build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fuzz/oss-fuzz-build.sh b/fuzz/oss-fuzz-build.sh index a59c8e34e..93a46f60e 100755 --- a/fuzz/oss-fuzz-build.sh +++ b/fuzz/oss-fuzz-build.sh @@ -26,7 +26,9 @@ cd fuzz make clean-corpus make fuzz.o -for fuzzer in api html reader regexp schema uri valid xinclude xml xpath; do +for fuzzer in \ + api html lint reader regexp schema uri valid xinclude xml xpath +do make $fuzzer.o # Link with $CXX $CXX $CXXFLAGS \ From 592546267fdde8ed57be99e168be5658417f42bd Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 14 May 2024 12:08:17 +0200 Subject: [PATCH 456/504] threads: Deprecate remaining ThrDef functions --- include/libxml/xmlIO.h | 2 ++ include/libxml/xmlerror.h | 2 ++ include/libxml/xmlsave.h | 3 +++ python/generator.py | 3 +++ python/libxml.c | 2 ++ 5 files changed, 12 insertions(+) diff --git a/include/libxml/xmlIO.h b/include/libxml/xmlIO.h index 4165bb38a..66eebd42d 100644 --- a/include/libxml/xmlIO.h +++ b/include/libxml/xmlIO.h @@ -418,9 +418,11 @@ XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLPUBFUN xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameDefault( xmlOutputBufferCreateFilenameFunc func); +XML_DEPRECATED XMLPUBFUN xmlOutputBufferCreateFilenameFunc xmlThrDefOutputBufferCreateFilenameDefault( xmlOutputBufferCreateFilenameFunc func); +XML_DEPRECATED XMLPUBFUN xmlParserInputBufferCreateFilenameFunc xmlThrDefParserInputBufferCreateFilenameDefault( xmlParserInputBufferCreateFilenameFunc func); diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h index 7d83f451d..c77db6b36 100644 --- a/include/libxml/xmlerror.h +++ b/include/libxml/xmlerror.h @@ -892,6 +892,7 @@ XML_GLOBALS_ERROR XMLPUBFUN void xmlSetGenericErrorFunc (void *ctx, xmlGenericErrorFunc handler); +XML_DEPRECATED XMLPUBFUN void xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler); @@ -902,6 +903,7 @@ XMLPUBFUN void XMLPUBFUN void xmlSetStructuredErrorFunc (void *ctx, xmlStructuredErrorFunc handler); +XML_DEPRECATED XMLPUBFUN void xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler); diff --git a/include/libxml/xmlsave.h b/include/libxml/xmlsave.h index 86b6285f7..e266e467c 100644 --- a/include/libxml/xmlsave.h +++ b/include/libxml/xmlsave.h @@ -82,10 +82,13 @@ XMLPUBFUN int xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt, xmlCharEncodingOutputFunc escape); +XML_DEPRECATED XMLPUBFUN int xmlThrDefIndentTreeOutput(int v); +XML_DEPRECATED XMLPUBFUN const char * xmlThrDefTreeIndentString(const char * v); +XML_DEPRECATED XMLPUBFUN int xmlThrDefSaveNoEmptyTags(int v); diff --git a/python/generator.py b/python/generator.py index 466a2e68a..149e0dfeb 100755 --- a/python/generator.py +++ b/python/generator.py @@ -388,12 +388,15 @@ def enum(type, name, value): 'xmlThrDefDefaultBufferSize': True, 'xmlThrDefDoValidityCheckingDefaultValue': True, 'xmlThrDefGetWarningsDefaultValue': True, + 'xmlThrDefIndentTreeOutput': True, 'xmlThrDefKeepBlanksDefaultValue': True, 'xmlThrDefLineNumbersDefaultValue': True, 'xmlThrDefLoadExtDtdDefaultValue': True, 'xmlThrDefParserDebugEntities': True, 'xmlThrDefPedanticParserDefaultValue': True, + 'xmlThrDefSaveNoEmptyTags': True, 'xmlThrDefSubstituteEntitiesDefaultValue': True, + 'xmlThrDefTreeIndentString': True, 'xmlValidCtxtNormalizeAttributeValue': True, 'xmlValidNormalizeAttributeValue': True, 'xmlValidateAttributeValue': True, diff --git a/python/libxml.c b/python/libxml.c index 5b30b34ab..681091e34 100644 --- a/python/libxml.c +++ b/python/libxml.c @@ -1510,7 +1510,9 @@ static void libxml_xmlErrorInitialize(void) { xmlSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler); +XML_IGNORE_DEPRECATION_WARNINGS xmlThrDefSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler); +XML_POP_WARNINGS } static PyObject * From 8d215ac5cc93aef4cc94fb0fc79c376c065ebdd1 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 14 May 2024 15:55:18 +0200 Subject: [PATCH 457/504] xpath: Fix quadratic runtime accounting --- xpath.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xpath.c b/xpath.c index d56057d0e..104008e14 100644 --- a/xpath.c +++ b/xpath.c @@ -8320,12 +8320,15 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) { * Account for quadratic runtime */ if (ctxt->context->opLimit != 0) { - unsigned long f1 = xmlStrlen(from->stringval) / 100; + unsigned long f1 = xmlStrlen(from->stringval); unsigned long f2 = xmlStrlen(str->stringval); if ((f1 > 0) && (f2 > 0)) { - unsigned long p = f1 > ULONG_MAX / f2 ? ULONG_MAX : f1 * f2; + unsigned long p; + f1 = f1 / 10 + 1; + f2 = f2 / 10 + 1; + p = f1 > ULONG_MAX / f2 ? ULONG_MAX : f1 * f2; if (xmlXPathCheckOpLimit(ctxt, p) < 0) goto error; } From ec2f68f16442cb536ed5a50e23e5d6b60289433f Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 14 May 2024 15:58:44 +0200 Subject: [PATCH 458/504] parser: Report malloc failure in xmlNewInputFromFile --- parserInternals.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/parserInternals.c b/parserInternals.c index 39d0007df..ae7d05b46 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -2033,7 +2033,8 @@ xmlParserInputPtr xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { xmlParserInputBufferPtr buf; xmlParserInputPtr inputStream; - xmlChar *URI = NULL; + const xmlChar *URI; + xmlChar *canonic; int code; if ((ctxt == NULL) || (filename == NULL)) @@ -2058,12 +2059,18 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { return(NULL); if (inputStream->filename == NULL) - URI = xmlStrdup((xmlChar *) filename); + URI = (xmlChar *) filename; else - URI = xmlStrdup((xmlChar *) inputStream->filename); - if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename); - inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI); - if (URI != NULL) xmlFree((char *) URI); + URI = (xmlChar *) inputStream->filename; + canonic = xmlCanonicPath(URI); + if (canonic == NULL) { + xmlCtxtErrMemory(ctxt); + xmlFreeInputStream(inputStream); + return(NULL); + } + if (inputStream->filename != NULL) + xmlFree((char *) inputStream->filename); + inputStream->filename = (char *) canonic; xmlBufResetInput(inputStream->buf->buffer, inputStream); From f895af0989d63db1f70b946cccf90e6d5827f9af Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 14 May 2024 16:08:37 +0200 Subject: [PATCH 459/504] fuzz: Remove OSS-Fuzz timeout option Custom timeouts aren't fully supported on OSS-Fuzz. --- fuzz/html.options | 2 -- fuzz/regexp.options | 2 -- fuzz/schema.options | 2 -- fuzz/uri.options | 2 -- fuzz/valid.options | 1 - fuzz/xinclude.options | 1 - fuzz/xml.options | 2 -- fuzz/xpath.options | 2 -- 8 files changed, 14 deletions(-) delete mode 100644 fuzz/html.options delete mode 100644 fuzz/regexp.options delete mode 100644 fuzz/schema.options delete mode 100644 fuzz/uri.options delete mode 100644 fuzz/xml.options delete mode 100644 fuzz/xpath.options diff --git a/fuzz/html.options b/fuzz/html.options deleted file mode 100644 index 1c63f53d8..000000000 --- a/fuzz/html.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -timeout = 10 diff --git a/fuzz/regexp.options b/fuzz/regexp.options deleted file mode 100644 index ea2a7a237..000000000 --- a/fuzz/regexp.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -timeout = 5 diff --git a/fuzz/schema.options b/fuzz/schema.options deleted file mode 100644 index e5d3bbee1..000000000 --- a/fuzz/schema.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -timeout = 20 diff --git a/fuzz/uri.options b/fuzz/uri.options deleted file mode 100644 index 0676c6595..000000000 --- a/fuzz/uri.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -timeout = 2 diff --git a/fuzz/valid.options b/fuzz/valid.options index dda14e08e..6335e163b 100644 --- a/fuzz/valid.options +++ b/fuzz/valid.options @@ -1,3 +1,2 @@ [libfuzzer] dict = xml.dict -timeout = 20 diff --git a/fuzz/xinclude.options b/fuzz/xinclude.options index dda14e08e..6335e163b 100644 --- a/fuzz/xinclude.options +++ b/fuzz/xinclude.options @@ -1,3 +1,2 @@ [libfuzzer] dict = xml.dict -timeout = 20 diff --git a/fuzz/xml.options b/fuzz/xml.options deleted file mode 100644 index e5d3bbee1..000000000 --- a/fuzz/xml.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -timeout = 20 diff --git a/fuzz/xpath.options b/fuzz/xpath.options deleted file mode 100644 index e5d3bbee1..000000000 --- a/fuzz/xpath.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -timeout = 20 From 51b5d1e378619533443e7fad364c83a474761995 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 15 May 2024 16:09:05 +0200 Subject: [PATCH 460/504] fuzz: Don't enable zlib and liblzma with MSan We'd need our own instrumented builds of these libraries. --- fuzz/oss-fuzz-build.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fuzz/oss-fuzz-build.sh b/fuzz/oss-fuzz-build.sh index 93a46f60e..151255bfb 100755 --- a/fuzz/oss-fuzz-build.sh +++ b/fuzz/oss-fuzz-build.sh @@ -11,15 +11,21 @@ if [ "$SANITIZER" = undefined ]; then export CXXFLAGS="$CXXFLAGS $extra_cflags" fi +# Don't enable zlib and liblzma with MSan +if [ "$SANITIZER" = memory ]; then + CONFIG='' +else + CONFIG='--with-zlib --with-lzma' +fi + export V=1 ./autogen.sh \ --disable-shared \ - --with-zlib \ - --with-lzma \ --without-debug \ --without-http \ - --without-python + --without-python \ + $CONFIG make -j$(nproc) cd fuzz From 4fefba4cf63acbb17c9f9cee90b8a3b5213a2b8c Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 15 May 2024 17:52:20 +0200 Subject: [PATCH 461/504] parser: Rework handling of undeclared entities Throw an error if entity substitution was requested. Now we only downgrade to a warning if - XML_PARSE_DTDLOAD wasn't specified, and - entity aren't substituted or XML_PARSE_NO_XXE was specified. Should fix #724. --- parser.c | 160 +++++++++++++----------- result/errors/rec_att_default.xml.ent | 2 +- result/noent/undeclared-entity.xml.sax2 | 4 +- 3 files changed, 92 insertions(+), 74 deletions(-) diff --git a/parser.c b/parser.c index ea475951f..ff8aae6e0 100644 --- a/parser.c +++ b/parser.c @@ -349,6 +349,23 @@ xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, val, NULL, NULL, 0, msg, val); } +/** + * xmlErrMsgStr: + * @ctxt: an XML parser context + * @error: the error number + * @msg: the error message + * @val: a string value + * + * Handle a non fatal parser error + */ +static void LIBXML_ATTR_FORMAT(3,0) +xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, + const char *msg, const xmlChar * val) +{ + xmlCtxtErr(ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_ERROR, + val, NULL, NULL, 0, msg, val); +} + /** * xmlNsErr: * @ctxt: an XML parser context @@ -7501,6 +7518,65 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { } } +static void +xmlHandleUndeclaredEntity(xmlParserCtxtPtr ctxt, const xmlChar *name) { + /* + * [ WFC: Entity Declared ] + * In a document without any DTD, a document with only an + * internal DTD subset which contains no parameter entity + * references, or a document with "standalone='yes'", the + * Name given in the entity reference must match that in an + * entity declaration, except that well-formed documents + * need not declare any of the following entities: amp, lt, + * gt, apos, quot. + * The declaration of a parameter entity must precede any + * reference to it. + * Similarly, the declaration of a general entity must + * precede any reference to it which appears in a default + * value in an attribute-list declaration. Note that if + * entities are declared in the external subset or in + * external parameter entities, a non-validating processor + * is not obligated to read and process their declarations; + * for such documents, the rule that an entity must be + * declared is a well-formedness constraint only if + * standalone='yes'. + */ + if ((ctxt->standalone == 1) || + ((ctxt->hasExternalSubset == 0) && + (ctxt->hasPErefs == 0))) { + xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, + "Entity '%s' not defined\n", name); + } else if (ctxt->validate) { + /* + * [ VC: Entity Declared ] + * In a document with an external subset or external + * parameter entities with "standalone='no'", ... + * ... The declaration of a parameter entity must + * precede any reference to it... + */ + xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, + "Entity '%s' not defined\n", name, NULL); + } else if ((ctxt->loadsubset) || + ((ctxt->replaceEntities) && + ((ctxt->options & XML_PARSE_NO_XXE) == 0))) { + /* + * Also raise a non-fatal error + * + * - if the external subset is loaded and all entity declarations + * should be available, or + * - entity substition was requested without restricting + * external entity access. + */ + xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY, + "Entity '%s' not defined\n", name); + } else { + xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, + "Entity '%s' not defined\n", name, NULL); + } + + ctxt->valid = 0; +} + static xmlEntityPtr xmlLookupGeneralEntity(xmlParserCtxtPtr ctxt, const xmlChar *name, int inAttr) { xmlEntityPtr ent; @@ -7529,49 +7605,9 @@ xmlLookupGeneralEntity(xmlParserCtxtPtr ctxt, const xmlChar *name, int inAttr) { ent = xmlSAX2GetEntity(ctxt, name); } } - /* - * [ WFC: Entity Declared ] - * In a document without any DTD, a document with only an - * internal DTD subset which contains no parameter entity - * references, or a document with "standalone='yes'", the - * Name given in the entity reference must match that in an - * entity declaration, except that well-formed documents - * need not declare any of the following entities: amp, lt, - * gt, apos, quot. - * The declaration of a parameter entity must precede any - * reference to it. - * Similarly, the declaration of a general entity must - * precede any reference to it which appears in a default - * value in an attribute-list declaration. Note that if - * entities are declared in the external subset or in - * external parameter entities, a non-validating processor - * is not obligated to read and process their declarations; - * for such documents, the rule that an entity must be - * declared is a well-formedness constraint only if - * standalone='yes'. - */ + if (ent == NULL) { - if (((!ctxt->validate) && (ctxt->loadsubset)) || - (ctxt->standalone == 1) || - ((ctxt->hasExternalSubset == 0) && - (ctxt->hasPErefs == 0))) { - xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, - "Entity '%s' not defined\n", name); - } else if (ctxt->validate) { - /* - * [ VC: Entity Declared ] - * In a document with an external subset or external - * parameter entities with "standalone='no'", ... - * ... The declaration of a parameter entity must - * precede any reference to it... - */ - xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, - "Entity '%s' not defined\n", name, NULL); - } else { - xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, - "Entity '%s' not defined\n", name, NULL); - } - ctxt->valid = 0; + xmlHandleUndeclaredEntity(ctxt, name); } /* @@ -7776,27 +7812,18 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) NEXT; + /* Must be set before xmlHandleUndeclaredEntity */ + ctxt->hasPErefs = 1; + /* * Request the entity from SAX */ if ((ctxt->sax != NULL) && (ctxt->sax->getParameterEntity != NULL)) entity = ctxt->sax->getParameterEntity(ctxt->userData, name); + if (entity == NULL) { - if (((!ctxt->validate) && (ctxt->loadsubset)) || - (ctxt->standalone == 1)) { - xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", - name); - } else if (ctxt->validate) { - xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", - name, NULL); - } else { - xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", - name, NULL); - } + xmlHandleUndeclaredEntity(ctxt, name); } else { /* * Internal checking in case the entity quest barfed @@ -7838,7 +7865,6 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) } } } - ctxt->hasPErefs = 1; } /** @@ -8033,26 +8059,18 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { } ptr++; + /* Must be set before xmlHandleUndeclaredEntity */ + ctxt->hasPErefs = 1; + /* * Request the entity from SAX */ if ((ctxt->sax != NULL) && (ctxt->sax->getParameterEntity != NULL)) entity = ctxt->sax->getParameterEntity(ctxt->userData, name); + if (entity == NULL) { - if (((!ctxt->validate) && (ctxt->loadsubset)) || - (ctxt->standalone == 1)) { - xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", name); - } else if (ctxt->validate) { - xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", - name, NULL); - } else { - xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, - "PEReference: %%%s; not found\n", - name, NULL); - } + xmlHandleUndeclaredEntity(ctxt, name); } else { /* * Internal checking in case the entity quest barfed @@ -8064,7 +8082,7 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { name, NULL); } } - ctxt->hasPErefs = 1; + xmlFree(name); *str = ptr; return(entity); diff --git a/result/errors/rec_att_default.xml.ent b/result/errors/rec_att_default.xml.ent index 345058419..375a0d651 100644 --- a/result/errors/rec_att_default.xml.ent +++ b/result/errors/rec_att_default.xml.ent @@ -1,4 +1,4 @@ -./test/errors/rec_att_default.xml:3: parser warning : Entity 'b' not defined +./test/errors/rec_att_default.xml:3: parser error : Entity 'b' not defined ^ ./test/errors/rec_att_default.xml:6: parser error : Detected an entity reference loop diff --git a/result/noent/undeclared-entity.xml.sax2 b/result/noent/undeclared-entity.xml.sax2 index 60eaaea2e..61f25bf49 100644 --- a/result/noent/undeclared-entity.xml.sax2 +++ b/result/noent/undeclared-entity.xml.sax2 @@ -7,7 +7,7 @@ SAX.startElementNs(doc, NULL, NULL, 0, 0, 0) SAX.characters( , 5) SAX.getEntity(undeclared) -SAX.warning: Entity 'undeclared' not defined +SAX.error: Entity 'undeclared' not defined SAX.startElementNs(elem, NULL, NULL, 0, 1, 0, attr='"/> ...', 0) SAX.endElementNs(elem, NULL, NULL) @@ -15,7 +15,7 @@ SAX.characters( , 5) SAX.startElementNs(elem, NULL, NULL, 0, 0, 0) SAX.getEntity(undeclared) -SAX.warning: Entity 'undeclared' not defined +SAX.error: Entity 'undeclared' not defined SAX.endElementNs(elem, NULL, NULL) SAX.characters( , 1) From caa8bb38483657a512b85cf393db753ec456855c Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 19 May 2024 19:31:54 +0200 Subject: [PATCH 462/504] fuzz: Move back to xmlSetExternalEntityLoader xmlParserInputBufferCreateFilenameDefault can't report malloc failures. --- fuzz/api.c | 2 +- fuzz/fuzz.c | 27 ++++++++++++++++++++++++--- fuzz/fuzz.h | 4 ++-- fuzz/lint.c | 2 +- fuzz/reader.c | 2 +- fuzz/schema.c | 2 +- fuzz/testFuzzer.c | 2 +- fuzz/valid.c | 2 +- fuzz/xinclude.c | 2 +- fuzz/xml.c | 2 +- xmllint.c | 2 ++ 11 files changed, 36 insertions(+), 13 deletions(-) diff --git a/fuzz/api.c b/fuzz/api.c index 80323ef45..3ac5c1fc0 100644 --- a/fuzz/api.c +++ b/fuzz/api.c @@ -964,7 +964,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/fuzz.c b/fuzz/fuzz.c index 557343ab1..3d0dbe1e2 100644 --- a/fuzz/fuzz.c +++ b/fuzz/fuzz.c @@ -391,8 +391,10 @@ xmlFuzzMainEntity(size_t *size) { * * The entity loader for fuzz data. */ -xmlParserInputBufferPtr -xmlFuzzEntityLoader(const char *URL, xmlCharEncoding enc) { +xmlParserInputPtr +xmlFuzzEntityLoader(const char *URL, const char *ID ATTRIBUTE_UNUSED, + xmlParserCtxtPtr ctxt) { + xmlParserInputPtr input; xmlFuzzEntityInfo *entity; if (URL == NULL) @@ -401,7 +403,26 @@ xmlFuzzEntityLoader(const char *URL, xmlCharEncoding enc) { if (entity == NULL) return(NULL); - return(xmlParserInputBufferCreateMem(entity->data, entity->size, enc)); + input = xmlNewInputStream(ctxt); + if (input == NULL) + return(NULL); + input->filename = (char *) xmlCharStrdup(URL); + if (input->filename == NULL) { + xmlCtxtErrMemory(ctxt); + xmlFreeInputStream(input); + return(NULL); + } + input->buf = xmlParserInputBufferCreateMem(entity->data, entity->size, + XML_CHAR_ENCODING_NONE); + if (input->buf == NULL) { + xmlCtxtErrMemory(ctxt); + xmlFreeInputStream(input); + return(NULL); + } + input->base = input->cur = xmlBufContent(input->buf->buffer); + input->end = input->base + xmlBufUse(input->buf->buffer); + + return input; } char * diff --git a/fuzz/fuzz.h b/fuzz/fuzz.h index 592f44134..d07925f6e 100644 --- a/fuzz/fuzz.h +++ b/fuzz/fuzz.h @@ -104,8 +104,8 @@ xmlFuzzMainUrl(void); const char * xmlFuzzMainEntity(size_t *size); -xmlParserInputBufferPtr -xmlFuzzEntityLoader(const char *URL, xmlCharEncoding enc); +xmlParserInputPtr +xmlFuzzEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt); char * xmlSlurpFile(const char *path, size_t *size); diff --git a/fuzz/lint.c b/fuzz/lint.c index 8a92829f1..5e71d0e81 100644 --- a/fuzz/lint.c +++ b/fuzz/lint.c @@ -198,7 +198,7 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) { pushArg(NULL); xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); #ifdef LIBXML_CATALOG_ENABLED xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif diff --git a/fuzz/reader.c b/fuzz/reader.c index 7935d238c..5721d356a 100644 --- a/fuzz/reader.c +++ b/fuzz/reader.c @@ -102,7 +102,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/schema.c b/fuzz/schema.c index a9111fca1..611deeca2 100644 --- a/fuzz/schema.c +++ b/fuzz/schema.c @@ -18,7 +18,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/testFuzzer.c b/fuzz/testFuzzer.c index a0543e5b1..0b6aa1da9 100644 --- a/fuzz/testFuzzer.c +++ b/fuzz/testFuzzer.c @@ -162,7 +162,7 @@ testEntityLoader(void) { xmlDocPtr doc; int ret = 0; - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); xmlFuzzDataInit(data, sizeof(data) - 1); xmlFuzzReadEntities(); diff --git a/fuzz/valid.c b/fuzz/valid.c index df896df0a..67b2fb246 100644 --- a/fuzz/valid.c +++ b/fuzz/valid.c @@ -20,7 +20,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/xinclude.c b/fuzz/xinclude.c index 53bef1ccc..e38a69e08 100644 --- a/fuzz/xinclude.c +++ b/fuzz/xinclude.c @@ -21,7 +21,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); return 0; } diff --git a/fuzz/xml.c b/fuzz/xml.c index ef017c86e..31ab21022 100644 --- a/fuzz/xml.c +++ b/fuzz/xml.c @@ -21,7 +21,7 @@ LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED, xmlCatalogSetDefaults(XML_CATA_ALLOW_NONE); #endif xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc); - xmlParserInputBufferCreateFilenameDefault(xmlFuzzEntityLoader); + xmlSetExternalEntityLoader(xmlFuzzEntityLoader); return 0; } diff --git a/xmllint.c b/xmllint.c index 4bdf54390..4cf865b1d 100644 --- a/xmllint.c +++ b/xmllint.c @@ -3506,7 +3506,9 @@ xmllintMain(int argc, const char **argv) { else if ((!strcmp(argv[i], "-nonet")) || (!strcmp(argv[i], "--nonet"))) { options |= XML_PARSE_NONET; +#ifndef XMLLINT_FUZZ xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader); +#endif } else if ((!strcmp(argv[i], "-nocompact")) || (!strcmp(argv[i], "--nocompact"))) { options &= ~XML_PARSE_COMPACT; From b47a95fe317ebc7cf736c849c864ef94aa203603 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 May 2024 13:10:41 +0200 Subject: [PATCH 463/504] parser: Don't make xmlCtxtErrIO public --- include/libxml/parserInternals.h | 4 ---- include/private/parser.h | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h index a5ca057c0..c4d4363b5 100644 --- a/include/libxml/parserInternals.h +++ b/include/libxml/parserInternals.h @@ -318,10 +318,6 @@ XMLPUBFUN xmlParserCtxtPtr const xmlChar *base); XMLPUBFUN void xmlCtxtErrMemory (xmlParserCtxtPtr ctxt); -XMLPUBFUN void - xmlCtxtErrIO (xmlParserCtxtPtr ctxt, - int code, - const char *uri); XMLPUBFUN int xmlSwitchEncoding (xmlParserCtxtPtr ctxt, xmlCharEncoding enc); diff --git a/include/private/parser.h b/include/private/parser.h index d7bb782a6..b14bebf91 100644 --- a/include/private/parser.h +++ b/include/private/parser.h @@ -57,6 +57,9 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info); XML_HIDDEN void LIBXML_ATTR_FORMAT(3,0) xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, const xmlChar *str1, const xmlChar *str2); +XML_HIDDEN void +xmlCtxtErrIO(xmlParserCtxtPtr ctxt, int code, const char *uri); + XML_HIDDEN void xmlHaltParser(xmlParserCtxtPtr ctxt); XML_HIDDEN int From a800e0035c7cb546a8955b964cde9418ee91c176 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 May 2024 13:54:09 +0200 Subject: [PATCH 464/504] doc: Allow missing desc if we have a retdesc Allow missing function descriptions if the return value is documented. --- doc/apibuild.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/apibuild.py b/doc/apibuild.py index 798224058..8575ed044 100755 --- a/doc/apibuild.py +++ b/doc/apibuild.py @@ -905,7 +905,7 @@ def mergeFunctionComment(self, name, description, quiet = 0): i = i + 1 if retdesc == "" and ret[0] != "void": self.warning("Function comment for %s lacks description of return value" % (name)) - if desc == "": + if desc == "" and retdesc == "": self.warning("Function comment for %s lacks description of the function" % (name)) return(((ret[0], retdesc), args, desc)) @@ -1774,7 +1774,8 @@ def serialize_function(self, output, name): try: (ret, params, desc) = id.info if (desc == None or desc == '') and \ - name[0:9] != "xmlThrDef" and name != "xmlDllMain": + name[0:9] != "xmlThrDef" and name != "xmlDllMain" and \ + ret[1] == '': print("%s %s from %s has no description" % (id.type, name, self.modulename_file(id.module))) From 9523438ad48cda1dd8c8c454e285354100cfb817 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 May 2024 13:56:47 +0200 Subject: [PATCH 465/504] doc: Allow missing author --- doc/apibuild.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/apibuild.py b/doc/apibuild.py index 8575ed044..9255413ba 100755 --- a/doc/apibuild.py +++ b/doc/apibuild.py @@ -1809,7 +1809,8 @@ def serialize_exports(self, output, file): escape(dict.info[data]), data.lower())) except: - print("Header %s lacks a %s description" % (module, data)) + if data != 'Author': + print("Header %s lacks a %s description" % (module, data)) if 'Description' in dict.info: desc = dict.info['Description'] if desc.find("DEPRECATED") != -1: From e75e878e0291431c947a80319800715a33ae4261 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 May 2024 13:58:22 +0200 Subject: [PATCH 466/504] doc: Update and fix documentation --- HTMLparser.c | 3 +++ dict.c | 42 +++++++++++++++++++++++++++++++ entities.c | 7 +++++- error.c | 4 ++- globals.c | 9 +++++++ hash.c | 12 +++++++++ include/libxml/encoding.h | 2 ++ include/libxml/xmlerror.h | 2 ++ parser.c | 12 ++++----- parserInternals.c | 53 +++++++++++++++++++++++++++++---------- pattern.c | 4 ++- tree.c | 42 +++++++++++++++++++++++++++++-- uri.c | 10 +++++++- valid.c | 2 ++ xinclude.c | 2 ++ xmlIO.c | 24 ++++++++++++++++++ xmlmemory.c | 4 +-- xmlreader.c | 8 ++++++ xmlsave.c | 21 +++++++++++++++- xmlstring.c | 6 ++--- xpath.c | 4 +-- 21 files changed, 239 insertions(+), 34 deletions(-) diff --git a/HTMLparser.c b/HTMLparser.c index 11ccef524..3be746483 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -6305,9 +6305,12 @@ htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options) /** * htmlCtxtParseDocument: * @ctxt: an HTML parser context + * @input: parser input * * Parse an HTML document and return the resulting document tree. * + * Available since 2.13.0. + * * Returns the resulting document tree or NULL */ htmlDocPtr diff --git a/dict.c b/dict.c index c843bb7b8..49e1c6bf7 100644 --- a/dict.c +++ b/dict.c @@ -510,6 +510,15 @@ xmlDictHashQName(unsigned seed, const xmlChar *prefix, const xmlChar *name, return(h2 | MAX_HASH_SIZE); } +/** + * xmlDictComputeHash: + * @dict: dictionary + * @string: C string + * + * Compute the hash value of a C string. + * + * Returns the hash value. + */ unsigned xmlDictComputeHash(const xmlDict *dict, const xmlChar *string) { size_t len; @@ -518,6 +527,15 @@ xmlDictComputeHash(const xmlDict *dict, const xmlChar *string) { #define HASH_ROL31(x,n) ((x) << (n) | ((x) & 0x7FFFFFFF) >> (31 - (n))) +/** + * xmlDictCombineHash: + * @v1: first hash value + * @v2: second hash value + * + * Combine two hash values. + * + * Returns the combined hash value. + */ ATTRIBUTE_NO_SANITIZE_INTEGER unsigned xmlDictCombineHash(unsigned v1, unsigned v2) { @@ -925,6 +943,11 @@ static xmlMutex xmlRngMutex; static unsigned globalRngState[2]; +/* + * xmlInitRandom: + * + * Initialize the PRNG. + */ ATTRIBUTE_NO_SANITIZE_INTEGER void xmlInitRandom(void) { @@ -966,6 +989,11 @@ xmlInitRandom(void) { } } +/* + * xmlCleanupRandom: + * + * Clean up PRNG globals. + */ void xmlCleanupRandom(void) { xmlCleanupMutex(&xmlRngMutex); @@ -985,6 +1013,13 @@ xoroshiro64ss(unsigned *s) { return(result & 0xFFFFFFFF); } +/* + * xmlGlobalRandom: + * + * Generate a pseudo-random value using the global PRNG. + * + * Returns a random value. + */ unsigned xmlGlobalRandom(void) { unsigned ret; @@ -996,6 +1031,13 @@ xmlGlobalRandom(void) { return(ret); } +/* + * xmlRandom: + * + * Generate a pseudo-random value using the thread-local PRNG. + * + * Returns a random value. + */ unsigned xmlRandom(void) { #ifdef LIBXML_THREAD_ENABLED diff --git a/entities.c b/entities.c index 6297c758f..28e2481c1 100644 --- a/entities.c +++ b/entities.c @@ -70,7 +70,10 @@ static const xmlEntity xmlEntityApos = { }; /* - * xmlFreeEntity : clean-up an entity record. + * xmlFreeEntity: + * @entity: an entity + * + * Frees the entity. */ void xmlFreeEntity(xmlEntityPtr entity) @@ -174,6 +177,8 @@ xmlCreateEntity(xmlDocPtr doc, const xmlChar *name, int type, * * Register a new entity for this document. * + * Available since 2.13.0. + * * Returns an xmlParserErrors error code. */ int diff --git a/error.c b/error.c index 083441bd5..b678a0ee0 100644 --- a/error.c +++ b/error.c @@ -409,6 +409,8 @@ xmlParserPrintFileContext(xmlParserInputPtr input) { * * This can result in a verbose multi-line report including additional * information from the parser context. + * + * Available since 2.13.0. */ void xmlFormatError(const xmlError *err, xmlGenericErrorFunc channel, void *data) @@ -662,7 +664,7 @@ xmlRaiseMemoryError(xmlStructuredErrorFunc schannel, xmlGenericErrorFunc channel * @channel: the old callback channel * @data: the callback data * @ctx: the parser context or NULL - * @ctx: the parser context or NULL + * @node: the current node or NULL * @domain: the domain for the error * @code: the code for the error * @level: the xmlErrorLevel for the error diff --git a/globals.c b/globals.c index 1e666bdcf..d5ef2065b 100644 --- a/globals.c +++ b/globals.c @@ -897,6 +897,11 @@ XML_GLOBALS_TREE #undef XML_OP #ifdef LIBXML_THREAD_ENABLED +/** + * xmlGetLocalRngState: + * + * Returns the local RNG state. + */ unsigned * xmlGetLocalRngState(void) { if (IS_MAIN_THREAD) @@ -975,6 +980,8 @@ xmlCheckThreadLocalStorage(void) { return(0); } +/** DOC_DISABLE */ + /** * DllMain: * @hinstDLL: handle to DLL instance @@ -1227,3 +1234,5 @@ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc fun return(old); } +/** DOC_ENABLE */ + diff --git a/hash.c b/hash.c index 33e8581ea..6af8527ea 100644 --- a/hash.c +++ b/hash.c @@ -608,6 +608,8 @@ xmlHashDefaultDeallocator(void *entry, const xmlChar *key ATTRIBUTE_UNUSED) { * can't be distinguished from out-of-memory errors, so this function * should be used with care. * + * Available since 2.13.0. + * * Returns 1 on success, 0 if an entry exists and -1 in case of error. */ int @@ -625,6 +627,10 @@ xmlHashAdd(xmlHashTablePtr hash, const xmlChar *key, void *payload) { * Add a hash table entry with two strings as key. * * See xmlHashAdd. + * + * Available since 2.13.0. + * + * Returns 1 on success, 0 if an entry exists and -1 in case of error. */ int xmlHashAdd2(xmlHashTablePtr hash, const xmlChar *key, @@ -643,6 +649,10 @@ xmlHashAdd2(xmlHashTablePtr hash, const xmlChar *key, * Add a hash table entry with three strings as key. * * See xmlHashAdd. + * + * Available since 2.13.0. + * + * Returns 1 on success, 0 if an entry exists and -1 in case of error. */ int xmlHashAdd3(xmlHashTablePtr hash, const xmlChar *key, @@ -1131,6 +1141,8 @@ xmlHashScanFull3(xmlHashTablePtr hash, const xmlChar *key, * * Copy the hash table using @copyFunc to copy payloads. * + * Available since 2.13.0. + * * Returns the new table or NULL if a memory allocation failed. */ xmlHashTablePtr diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h index 74b83d58c..599a03e12 100644 --- a/include/libxml/encoding.h +++ b/include/libxml/encoding.h @@ -202,7 +202,9 @@ XMLPUBFUN xmlCharEncoding xmlDetectCharEncoding (const unsigned char *in, int len); +/** DOC_DISABLE */ struct _xmlBuffer; +/** DOC_ENABLE */ XMLPUBFUN int xmlCharEncOutFunc (xmlCharEncodingHandler *handler, struct _xmlBuffer *out, diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h index c77db6b36..36381bec5 100644 --- a/include/libxml/xmlerror.h +++ b/include/libxml/xmlerror.h @@ -927,7 +927,9 @@ XMLPUBFUN void xmlParserValidityWarning (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); +/** DOC_DISABLE */ struct _xmlParserInput; +/** DOC_ENABLE */ XMLPUBFUN void xmlParserPrintFileInfo (struct _xmlParserInput *input); XMLPUBFUN void diff --git a/parser.c b/parser.c index ff8aae6e0..d550b1b63 100644 --- a/parser.c +++ b/parser.c @@ -11671,8 +11671,6 @@ xmlStopParser(xmlParserCtxtPtr ctxt) { * @ioctx: an I/O handler * @enc: the charset encoding if known (deprecated) * - * DEPRECATED: Use xmlNewParserCtxt and xmlCtxtReadIO. - * * Create a parser context for using the XML parser with an existing * I/O stream * @@ -12132,10 +12130,10 @@ xmlCtxtParseEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) { /** * xmlParseCtxtExternalEntity: - * @ctx: the existing parsing context + * @ctxt: the existing parsing context * @URL: the URL for the entity to load * @ID: the System ID for the entity to load - * @lst: the return value for the set of parsed nodes + * @listOut: the return value for the set of parsed nodes * * Parse an external general entity within an existing parsing context * An external general parsed entity is well-formed if it matches the @@ -12184,7 +12182,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctxt, const xmlChar *URL, * @depth: Used for loop detection, use 0 * @URL: the URL for the entity to load * @ID: the System ID for the entity to load - * @lst: the return value for the set of parsed nodes + * @list: the return value for the set of parsed nodes * * DEPRECATED: Use xmlParseCtxtExternalEntity. * @@ -12461,7 +12459,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen, * @user_data: The user data returned on SAX callbacks (possibly NULL) * @depth: Used for loop detection, use 0 * @string: the input string in UTF8 or ISO-Latin (zero terminated) - * @list: the return value for the set of parsed nodes + * @listOut: the return value for the set of parsed nodes * @recover: return nodes even if the data is broken (use 0) * * Parse a well-balanced chunk of an XML document @@ -13659,6 +13657,8 @@ xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt, unsigned maxAmpl) * Parse an XML document and return the resulting document tree. * Takes ownership of the input object. * + * Available since 2.13.0. + * * Returns the resulting document tree or NULL */ xmlDocPtr diff --git a/parserInternals.c b/parserInternals.c index ae7d05b46..a2fe5aad6 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -124,9 +124,10 @@ xmlCtxtSetErrorHandler(xmlParserCtxtPtr ctxt, xmlStructuredErrorFunc handler, /** * xmlCtxtErrMemory: * @ctxt: an XML parser context - * @domain: domain * - * Handle an out-of-memory error + * Handle an out-of-memory error. + * + * Available since 2.13.0. */ void xmlCtxtErrMemory(xmlParserCtxtPtr ctxt) @@ -209,6 +210,22 @@ xmlCtxtErrIO(xmlParserCtxtPtr ctxt, int code, const char *uri) msg, str1, str2); } +/** + * xmlCtxtVErr: + * @ctxt: a parser context + * @node: the current node or NULL + * @domain: the domain for the error + * @code: the code for the error + * @level: the xmlErrorLevel for the error + * @str1: extra string info + * @str2: extra string info + * @str3: extra string info + * @int1: extra int info + * @msg: the message to display/transmit + * @ap: extra parameters for the message display + * + * Raise a parser error. + */ void xmlCtxtVErr(xmlParserCtxtPtr ctxt, xmlNodePtr node, xmlErrorDomain domain, xmlParserErrors code, xmlErrorLevel level, @@ -299,6 +316,22 @@ xmlCtxtVErr(xmlParserCtxtPtr ctxt, xmlNodePtr node, xmlErrorDomain domain, return; } +/** + * xmlCtxtErr: + * @ctxt: a parser context + * @node: the current node or NULL + * @domain: the domain for the error + * @code: the code for the error + * @level: the xmlErrorLevel for the error + * @str1: extra string info + * @str2: extra string info + * @str3: extra string info + * @int1: extra int info + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Raise a parser error. + */ void xmlCtxtErr(xmlParserCtxtPtr ctxt, xmlNodePtr node, xmlErrorDomain domain, xmlParserErrors code, xmlErrorLevel level, @@ -316,7 +349,7 @@ xmlCtxtErr(xmlParserCtxtPtr ctxt, xmlNodePtr node, xmlErrorDomain domain, /** * xmlFatalErr: * @ctxt: an XML parser context - * @error: the error number + * @code: the error number * @info: extra information string * * Handle a fatal parser error, i.e. violating Well-Formedness constraints @@ -1069,6 +1102,8 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) * @input: the input strea, * @encoding: the encoding name * + * Available since 2.13.0. + * * Returns 0 in case of success, -1 otherwise */ static int @@ -1797,11 +1832,9 @@ xmlNewInputPush(xmlParserCtxtPtr ctxt, const char *url, /** * xmlNewIOInputStream: * @ctxt: an XML parser context - * @input: an I/O Input + * @buf: an input buffer * @enc: the charset encoding if known * - * DEPRECATED: Use xmlNewInputURL, xmlNewInputMemory, etc. - * * Create a new input stream structure encapsulating the @input into * a stream suitable for the parser. * @@ -1822,7 +1855,7 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr buf, /** * xmlNewEntityInputStream: * @ctxt: an XML parser context - * @entity: an Entity pointer + * @ent: an Entity pointer * * DEPRECATED: Internal function, do not use. * @@ -1860,8 +1893,6 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) { * @ctxt: an XML parser context * @buffer: an memory buffer * - * DEPRECATED: Use xmlNewInputString. - * * Create a new input stream based on a memory buffer. * * Returns the new input stream @@ -2023,8 +2054,6 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) { * @ctxt: an XML parser context * @filename: the filename to use as entity * - * DEPRECATED: Use xmlNewInputURL. - * * Create a new input stream based on a file or an URL. * * Returns the new input stream or NULL in case of error @@ -2199,8 +2228,6 @@ xmlGetExternalEntityLoader(void) { * @ID: the Public ID for the entity to load * @ctxt: the context in which the entity is called or NULL * - * DEPRECATED: Use xmlNewInputURL. - * * Returns the xmlParserInputPtr or NULL */ xmlParserInputPtr diff --git a/pattern.c b/pattern.c index d03d37939..2b6697680 100644 --- a/pattern.c +++ b/pattern.c @@ -2252,7 +2252,7 @@ xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt) ************************************************************************/ /** - * xmlPatterncompile: + * xmlPatternCompileSafe: * @pattern: the pattern to compile * @dict: an optional dictionary for interned strings * @flags: compilation flags, see xmlPatternFlags @@ -2261,6 +2261,8 @@ xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt) * * Compile a pattern. * + * Available since 2.13.0. + * * Returns 0 on success, 1 on error, -1 if a memory allocation failed. */ int diff --git a/tree.c b/tree.c index 71408be08..4202d717d 100644 --- a/tree.c +++ b/tree.c @@ -2157,7 +2157,6 @@ xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, /** * xmlNewDocNodeEatName: - * xmlNewDocNode: * @doc: the target document * @ns: namespace (optional) * @name: the node name @@ -4156,6 +4155,17 @@ xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) { * namespace info, but don't recurse on children. */ +/** + * xmlStaticCopyNode: + * @node: source node + * @doc: target document + * @parent: target parent + * @extended: flags + * + * Copy a node. + * + * Returns the copy or NULL if a memory allocation failed. + */ xmlNodePtr xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent, int extended) { @@ -5327,7 +5337,7 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) { #endif /* LIBXML_TREE_ENABLED */ /** - * xmlNodeGetBase: + * xmlNodeGetBaseSafe: * @doc: the document the node pertains to * @cur: the node being checked * @baseOut: pointer to base @@ -5341,6 +5351,8 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) { * However it does not return the document base (5.1.3), use * doc->URL in this case * + * Available since 2.13.0. + * * Return 0 in case of success, 1 if a URI or argument is invalid, -1 if a * memory allocation failed. */ @@ -5866,6 +5878,8 @@ xmlTextMerge(xmlNodePtr first, xmlNodePtr second) { * terminated array of namespace pointers that must be freed by * the caller. * + * Available since 2.13.0. + * * Returns 0 on success, 1 if no namespaces were found, -1 if a * memory allocation failed. */ @@ -5991,6 +6005,17 @@ xmlTreeEnsureXMLDecl(xmlDocPtr doc) return(ns); } +/** + * xmlSearchNsSafe: + * @node: a node + * @prefix: a namespace prefix + * @out: pointer to resulting namespace + * + * Search a namespace with @prefix in scope of @node. + * + * Returns 0 on success, -1 if a memory allocation failed, 1 on + * other errors. + */ int xmlSearchNsSafe(xmlNodePtr node, const xmlChar *prefix, xmlNsPtr *out) { @@ -6132,6 +6157,17 @@ xmlNsInScope(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node, return (1); } +/** + * xmlSearchNsByHrefSafe: + * @node: a node + * @href: a namespace URI + * @out: pointer to resulting namespace + * + * Search a namespace matching @URI in scope of @node. + * + * Returns 0 on success, -1 if a memory allocation failed, 1 on + * other errors. + */ int xmlSearchNsByHrefSafe(xmlNodePtr node, const xmlChar *href, xmlNsPtr *out) { @@ -6693,6 +6729,8 @@ xmlHasNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace) * This does the entity substitution. The returned value must be * freed by the caller. * + * Available since 2.13.0. + * * Returns 0 on success, 1 if no attribute was found, -1 if a * memory allocation failed. */ diff --git a/uri.c b/uri.c index 1470b5a6b..3803e0ded 100644 --- a/uri.c +++ b/uri.c @@ -970,6 +970,8 @@ xmlParse3986URIReference(xmlURIPtr uri, const char *str) { * * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] * + * Available since 2.13.0. + * * Returns 0 on success, an error code (typically 1) if the URI is invalid * or -1 if a memory allocation failed. */ @@ -1989,7 +1991,7 @@ xmlResolvePath(const xmlChar *escRef, const xmlChar *base, xmlChar **out) { } /** - * xmlBulidURISafe: + * xmlBuildURISafe: * @URI: the URI instance found in the document * @base: the base value * @valPtr: pointer to result URI @@ -2001,6 +2003,8 @@ xmlResolvePath(const xmlChar *escRef, const xmlChar *base, xmlChar **out) { * * 5.2. Resolving Relative References to Absolute Form * + * Available since 2.13.0. + * * Returns 0 on success, -1 if a memory allocation failed or an error * code if URI or base are invalid. */ @@ -2378,6 +2382,8 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) { * since this routine (for reasonable efficiency) assumes URI has * already been through some validation. * + * Available since 2.13.0. + * * Returns 0 on success, -1 if a memory allocation failed or an error * code if URI or base are invalid. */ @@ -2650,6 +2656,8 @@ xmlBuildRelativeURI(const xmlChar * URI, const xmlChar * base) * The caller is responsible for freeing the memory occupied * by the returned string. If there is insufficient memory available, or the * argument is NULL, the function returns NULL. + * + * Returns the escaped path. */ xmlChar * xmlCanonicPath(const xmlChar *path) diff --git a/valid.c b/valid.c index a7c4e4a17..c3c7ee179 100644 --- a/valid.c +++ b/valid.c @@ -2394,6 +2394,8 @@ xmlAddIDInternal(xmlAttrPtr attr, const xmlChar *value, xmlIDPtr *idPtr) { * * Register a new id declaration * + * Available since 2.13.0. + * * Returns 1 on success, 0 if the ID already exists, -1 if a memory * allocation fails. */ diff --git a/xinclude.c b/xinclude.c index 9741699ce..1a54f7c24 100644 --- a/xinclude.c +++ b/xinclude.c @@ -2207,6 +2207,8 @@ xmlXIncludeDoProcessRoot(xmlXIncludeCtxtPtr ctxt, xmlNodePtr tree) { * xmlXIncludeGetLastError: * @ctxt: an XInclude processing context * + * Available since 2.13.0. + * * Returns the last error code. */ int diff --git a/xmlIO.c b/xmlIO.c index 6789c7ee8..d4275cbfc 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -1651,6 +1651,8 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { * @enc: encoding enum (deprecated) * @out: pointer to resulting input buffer * + * Create an input buffer for a filename or URI. + * * Returns an xmlParserErrors code. */ int @@ -1937,6 +1939,17 @@ xmlMemClose(void *vctxt) { return(0); } +/** + * xmlNewInputBufferMemory: + * @mem: memory buffer + * @size: size of buffer + * @flags: flags + * @enc: the charset encoding if known (deprecated) + * + * Create an input buffer for memory. + * + * Returns the new input buffer or NULL. + */ xmlParserInputBufferPtr xmlNewInputBufferMemory(const void *mem, size_t size, int flags, xmlCharEncoding enc) { @@ -2059,6 +2072,15 @@ xmlStringClose(void *vctxt) { return(0); } +/** + * xmlNewInputBufferString: + * @str: C string + * @flags: flags + * + * Create an input buffer for a null-teriminated C string. + * + * Returns the new input buffer or NULL. + */ xmlParserInputBufferPtr xmlNewInputBufferString(const char *str, int flags) { xmlParserInputBufferPtr ret; @@ -2894,6 +2916,8 @@ xmlParserGetDirectory(const char *filename) { * DEPRECATED: Internal function, don't use. * * Like xmlCheckFilename but handles file URIs. + * + * Returns 0, 1, or 2. */ int xmlNoNetExists(const char *filename) { diff --git a/xmlmemory.c b/xmlmemory.c index a850dfa0c..f0628e2a8 100644 --- a/xmlmemory.c +++ b/xmlmemory.c @@ -395,6 +395,8 @@ xmlMemoryDump(void) * xmlInitMemory: * * DEPRECATED: Alias for xmlInitParser. + * + * Returns 0. */ int xmlInitMemory(void) { @@ -406,8 +408,6 @@ xmlInitMemory(void) { * xmlInitMemoryInternal: * * Initialize the memory layer. - * - * Returns 0 on success */ void xmlInitMemoryInternal(void) { diff --git a/xmlreader.c b/xmlreader.c index 3ad8d386c..2de91bf96 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -5042,6 +5042,14 @@ xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader, unsigned maxAmpl) xmlCtxtSetMaxAmplification(reader->ctxt, maxAmpl); } +/** + * xmlTextReaderGetLastError: + * @reader: an XML reader + * + * Available since 2.13.0. + * + * Returns the last error. + */ const xmlError * xmlTextReaderGetLastError(xmlTextReaderPtr reader) { diff --git a/xmlsave.c b/xmlsave.c index cf4e0583e..ba0015594 100644 --- a/xmlsave.c +++ b/xmlsave.c @@ -2164,6 +2164,15 @@ xmlSaveTree(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) return(ret); } +/** + * xmlSaveNotationDecl: + * @ctxt: save context + * @cur: notation + * + * Serialize a notation declaration. + * + * Return 0 on succes, -1 on error. + */ int xmlSaveNotationDecl(xmlSaveCtxtPtr ctxt, xmlNotationPtr cur) { if (ctxt == NULL) @@ -2172,6 +2181,15 @@ xmlSaveNotationDecl(xmlSaveCtxtPtr ctxt, xmlNotationPtr cur) { return(0); } +/** + * xmlSaveNotationTable: + * @ctxt: save context + * @cur: notation table + * + * Serialize notation declarations of a document. + * + * Return 0 on succes, -1 on error. + */ int xmlSaveNotationTable(xmlSaveCtxtPtr ctxt, xmlNotationTablePtr cur) { if (ctxt == NULL) @@ -2224,6 +2242,8 @@ xmlSaveClose(xmlSaveCtxtPtr ctxt) * Close a document saving context, i.e. make sure that all bytes have * been output and free the associated data. * + * Available since 2.13.0. + * * Returns an xmlParserErrors code. */ int @@ -2283,7 +2303,6 @@ xmlSaveSetAttrEscape(xmlSaveCtxtPtr ctxt, xmlCharEncodingOutputFunc escape) * xmlBufAttrSerializeTxtContent: * @buf: output buffer * @doc: the document - * @attr: the attribute node * @string: the text content * * Serialize text attribute values to an xmlBufPtr diff --git a/xmlstring.c b/xmlstring.c index 72e3453ec..258ecc92c 100644 --- a/xmlstring.c +++ b/xmlstring.c @@ -597,7 +597,7 @@ xmlStrVPrintf(xmlChar *buf, int len, const char *msg, va_list ap) { * xmlStrVASPrintf: * @out: pointer to the resulting string * @maxSize: maximum size of the output buffer - * @fmt: printf format string + * @msg: printf format string * @ap: arguments for format string * * Creates a newly allocated string according to format. @@ -715,8 +715,8 @@ xmlStrVASPrintf(xmlChar **out, int maxSize, const char *msg, va_list ap) { * xmlStrASPrintf: * @out: pointer to the resulting string * @maxSize: maximum size of the output buffer - * @fmt: printf format string - * @ap: arguments for format string + * @msg: printf format string + * @...: arguments for format string * * See xmlStrVASPrintf. * diff --git a/xpath.c b/xpath.c index 104008e14..0ddde8d4b 100644 --- a/xpath.c +++ b/xpath.c @@ -624,7 +624,6 @@ static const char* const xmlXPathErrorMessages[] = { /** * xmlXPathErrMemory: * @ctxt: an XPath context - * @extra: extra information * * Handle a memory allocation failure. */ @@ -640,7 +639,6 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt) /** * xmlXPathPErrMemory: * @ctxt: an XPath parser context - * @extra: extra information * * Handle a memory allocation failure. */ @@ -656,7 +654,7 @@ xmlXPathPErrMemory(xmlXPathParserContextPtr ctxt) /** * xmlXPathErr: * @ctxt: a XPath parser context - * @error: the error code + * @code: the error code * * Handle an XPath error */ From 5b1d7ff0b295fb0cadea86f9e9a57b9e461db03a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 May 2024 22:51:44 +0200 Subject: [PATCH 467/504] parser: Remove redefinitions for legacy globals --- include/libxml/parser.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/libxml/parser.h b/include/libxml/parser.h index 594e0f70a..86dd54f47 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -882,9 +882,6 @@ XML_GLOBALS_PARSER #undef XML_OP #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION) - #define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility) - #define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler) - #define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator) #define xmlDoValidityCheckingDefaultValue \ XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue) #define xmlGetWarningsDefaultValue \ From 3018842c07e9b88d6bb0257f5644e7695cdeb2e2 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 May 2024 23:51:01 +0200 Subject: [PATCH 468/504] build: Disable HTTP support by default --- CMakeLists.txt | 2 +- configure.ac | 29 ++++++++++++++++++++--------- meson.build | 2 ++ meson_options.txt | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00ccc3694..12e145896 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ option(LIBXML2_WITH_DEBUG "Add the debugging module" ON) set(LIBXML2_WITH_EXPR ON) option(LIBXML2_WITH_FTP "Add the FTP support" OFF) option(LIBXML2_WITH_HTML "Add the HTML support" ON) -option(LIBXML2_WITH_HTTP "Add the HTTP support" ON) +option(LIBXML2_WITH_HTTP "Add the HTTP support" OFF) option(LIBXML2_WITH_ICONV "Add ICONV support" ON) option(LIBXML2_WITH_ICU "Add ICU support" OFF) option(LIBXML2_WITH_ISO8859X "Add ISO8859X support if no iconv" ON) diff --git a/configure.ac b/configure.ac index 65dea7dc8..1dff49e84 100644 --- a/configure.ac +++ b/configure.ac @@ -140,6 +140,21 @@ AC_ARG_WITH(fexceptions, AC_ARG_WITH(coverage, [ --with-coverage build for code coverage with GCC (off)]) +dnl +dnl Legacy defaults +dnl +if test "$with_legacy" = "yes"; then + if test "$with_http" = ""; then + with_http=yes + fi + if test "$with_lzma" = ""; then + with_lzma=yes + fi + if test "$with_zlib" = ""; then + with_zlib=yes + fi +fi + dnl dnl hard dependencies on options dnl @@ -317,7 +332,7 @@ AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */ dnl dnl Checks for inet libraries dnl -if test "$with_http" != "no" || test "with_ftp" = "yes"; then +if test "$with_http" = "yes" || test "$with_ftp" = "yes"; then case "$host" in *-*-mingw*) dnl AC_SEARCH_LIBS doesn't work because of non-standard calling @@ -531,10 +546,10 @@ fi AC_SUBST(WITH_FTP) AM_CONDITIONAL(WITH_FTP_SOURCES, test "$WITH_FTP" = "1") -if test "$with_http" = "no" ; then - echo Disabling HTTP support +if test "$with_http" != "yes" ; then WITH_HTTP=0 else + echo Enabling HTTP support WITH_HTTP=1 fi AC_SUBST(WITH_HTTP) @@ -885,9 +900,7 @@ dnl Checks for zlib library. dnl WITH_ZLIB=0 -if test "$with_zlib" != "no" && \ - (test "$with_zlib" != "" || test "$with_legacy" = "yes") -then +if test "$with_zlib" != "no" && test "$with_zlib" != ""; then echo "Enabling zlib compression support" if test "$with_zlib" != "yes"; then @@ -939,9 +952,7 @@ dnl Checks for lzma library. dnl WITH_LZMA=0 -if test "$with_lzma" != "no" && \ - (test "$with_lzma" != "" || test "$with_legacy" = "yes") -then +if test "$with_lzma" != "no" && test "$with_lzma" != ""; then echo "Enabling lzma compression support" if test "$with_lzma" != "yes"; then diff --git a/meson.build b/meson.build index 13d966b33..31eb1ba8c 100644 --- a/meson.build +++ b/meson.build @@ -91,6 +91,8 @@ want_xptr = get_option('xptr') want_xptr_locs = get_option('xptr-locs') want_zlib = get_option('zlib') +# TODO: Legacy defaults + # hard dependencies on options if want_c14n == true diff --git a/meson_options.txt b/meson_options.txt index 48119c8e4..cbc212d1b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -87,7 +87,7 @@ option('html', option('http', type: 'boolean', - value: true, + value: false, description: 'HTTP support' ) From bd7cafdbceae6f9a4941b0244d289c0308e6291f Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 20 May 2024 23:46:37 +0200 Subject: [PATCH 469/504] meson: Add some TODO comments --- meson.build | 3 +++ meson_options.txt | 1 + python/tests/meson.build | 1 + 3 files changed, 5 insertions(+) diff --git a/meson.build b/meson.build index 31eb1ba8c..098f522e4 100644 --- a/meson.build +++ b/meson.build @@ -91,6 +91,8 @@ want_xptr = get_option('xptr') want_xptr_locs = get_option('xptr-locs') want_zlib = get_option('zlib') +# TODO: Options should be three-valued: "yes", "no", default + # TODO: Legacy defaults # hard dependencies on options @@ -178,6 +180,7 @@ endif # minimum dependencies if get_option('minimum') + # TODO: This is should allow other options want_c14n = false want_catalog = false want_debug = false diff --git a/meson_options.txt b/meson_options.txt index cbc212d1b..c147875cc 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -42,6 +42,7 @@ # [X] minimum # [X] ipv6 +# TODO: Options should be three-valued: "yes", "no", default option('c14n', type: 'boolean', diff --git a/python/tests/meson.build b/python/tests/meson.build index 1c56fddce..6065b009f 100644 --- a/python/tests/meson.build +++ b/python/tests/meson.build @@ -1,3 +1,4 @@ +# TODO: Run the tests python_test_files = files( 'attribs.py', From 1371d0bda20f5e909e94054f6f49d0a967ac5291 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 00:01:13 +0200 Subject: [PATCH 470/504] Update NEWS --- NEWS | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index d39727d63..51c8318a8 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,8 @@ v2.13.0: not released yet ### Major changes -Most of the core code should now report malloc failures reliably. +Most of the core code should now report malloc failures reliably. Some +API functions were extended with versions that report malloc failures. New API functions for error handling were added: @@ -18,12 +19,31 @@ resorting to global handlers. A few error messages were improved and consolidated. Please update downstream test suites accordingly. +A new parser option XML_PARSE_NO_XXE can be used to disable loading +of external entities or DTDs. This is most useful in connection with +XML_PARSE_NOENT. + Support for HTTP POST was removed. -Support for zlib and liblzma is now disabled by default and has to be -enabled by passing --with-zlib or --with-lzma to configure. In legacy -mode (--with-legacy) compression support is enabled by default as -before. +Support for zlib, liblzma and HTTP is now disabled by default and has +to be enabled by passing --with-zlib, --with-lzma or --with-html to +configure. In legacy mode (--with-legacy) these options are enabled +by default as before. + +Support for FTP and xpointer() XPath extensions will be removed in +the next release. + +Several more legacy symbols were deprecated. Users of the old "SAX1" +API functions are encouraged to upgrade to the new "SAX2" API, +available since version 2.6.0 from 2003. + +Some deprecated global variables were made const: + +- htmlDefaultSAXHandler +- oldXMLWDcompatibility +- xmlDefaultSAXHandler +- xmlDefaultSAXLocator +- xmlParserDebugEntities v2.12.0: Nov 16 2023 From dda69626b9e2e6bfa6e1233432152bcd486bb540 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 18:31:37 +0200 Subject: [PATCH 471/504] autotools: Only check for networking headers if required --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1dff49e84..325242d05 100644 --- a/configure.ac +++ b/configure.ac @@ -308,8 +308,6 @@ dnl AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_HEADERS([fcntl.h unistd.h sys/stat.h]) AC_CHECK_HEADERS([sys/mman.h]) -AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h netdb.h]) -AC_CHECK_HEADERS([sys/select.h poll.h]) AC_CHECK_HEADERS([sys/time.h sys/timeb.h]) AC_CHECK_HEADERS([sys/random.h]) AC_CHECK_HEADERS([dl.h dlfcn.h]) @@ -333,6 +331,9 @@ dnl dnl Checks for inet libraries dnl if test "$with_http" = "yes" || test "$with_ftp" = "yes"; then + AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h netdb.h]) + AC_CHECK_HEADERS([sys/select.h poll.h]) + case "$host" in *-*-mingw*) dnl AC_SEARCH_LIBS doesn't work because of non-standard calling From e80f27fc81b02655e593c1cd1c53ea4aa37f84c8 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 18:37:57 +0200 Subject: [PATCH 472/504] build: Don't check for inttypes.h This header isn't used. --- CMakeLists.txt | 1 - config.h.cmake.in | 3 --- configure.ac | 2 +- meson.build | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12e145896..613f0ab3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,6 @@ if (NOT MSVC) check_function_exists(ftime HAVE_FTIME) check_function_exists(getentropy HAVE_GETENTROPY) check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) - check_include_files(inttypes.h HAVE_INTTYPES_H) check_function_exists(isascii HAVE_ISASCII) check_library_exists(history append_history "" HAVE_LIBHISTORY) check_library_exists(readline readline "" HAVE_LIBREADLINE) diff --git a/config.h.cmake.in b/config.h.cmake.in index 2c1f91179..811e58875 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -28,9 +28,6 @@ /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine HAVE_GETTIMEOFDAY 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - /* Define to 1 if you have the `isascii' function. */ #cmakedefine HAVE_ISASCII 1 diff --git a/configure.ac b/configure.ac index 325242d05..e85db1604 100644 --- a/configure.ac +++ b/configure.ac @@ -305,7 +305,7 @@ XML_PC_REQUIRES= dnl dnl Checks for header files. dnl -AC_CHECK_HEADERS([stdint.h inttypes.h]) +AC_CHECK_HEADERS([stdint.h]) AC_CHECK_HEADERS([fcntl.h unistd.h sys/stat.h]) AC_CHECK_HEADERS([sys/mman.h]) AC_CHECK_HEADERS([sys/time.h sys/timeb.h]) diff --git a/meson.build b/meson.build index 098f522e4..0f2bfbe61 100644 --- a/meson.build +++ b/meson.build @@ -304,7 +304,6 @@ config_h.set_quoted('LOCALEDIR', dir_locale) # header files xml_check_headers = [ 'stdint.h', - 'inttypes.h', 'fcntl.h', 'unistd.h', 'sys/stat.h', From 54629e0f758baaa0e0a66a204b521f362414311d Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 20:25:23 +0200 Subject: [PATCH 473/504] autotools: Remove --with-coverage configuration option --- configure.ac | 11 ----------- meson_options.txt | 1 - 2 files changed, 12 deletions(-) diff --git a/configure.ac b/configure.ac index e85db1604..8da607b5d 100644 --- a/configure.ac +++ b/configure.ac @@ -137,8 +137,6 @@ AC_ARG_WITH(tls, [ --with-tls thread-local storage (off)]) AC_ARG_WITH(fexceptions, [ --with-fexceptions add GCC flag -fexceptions for C++ exceptions (off)]) -AC_ARG_WITH(coverage, -[ --with-coverage build for code coverage with GCC (off)]) dnl dnl Legacy defaults @@ -1107,15 +1105,6 @@ case "$host" in ;; esac -if test "$with_coverage" = "yes" && test "${GCC}" = "yes" -then - echo Enabling code coverage for GCC - AM_CFLAGS="$AM_CFLAGS -fprofile-arcs -ftest-coverage" - AM_LDFLAGS="$AM_LDFLAGS -fprofile-arcs -ftest-coverage" -else - echo Disabling code coverage for GCC -fi - XML_LIBS="-lxml2" XML_LIBTOOLLIBS="libxml2.la" NON_PC_LIBS="${THREAD_LIBS} ${ICONV_LIBS} ${LIBM} ${NET_LIBS} ${CRYPTO_LIBS}" diff --git a/meson_options.txt b/meson_options.txt index c147875cc..9c54df3a7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,7 +2,6 @@ # AC_ARG_WITH / AC_ARG_ENABLE in configure.ac # [X] c14n # [X] catalog -# [M] coverage - use meson, not minimum # [X] debugging # [X] fexceptions # [X] ftp - not minimum From 5c9e0ebe7192b43baad0d877ac9c8b27e18c7e94 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 20:27:45 +0200 Subject: [PATCH 474/504] autotools: Change ICU message Only log non-default actions. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8da607b5d..cba3c7c3a 100644 --- a/configure.ac +++ b/configure.ac @@ -1047,9 +1047,9 @@ dnl Checks for ICU library. dnl WITH_ICU=0 -if test "$with_icu" = "no" || test "$with_icu" = "" ; then - echo Disabling ICU support -else +if test "$with_icu" != "no" && test "$with_icu" != "" ; then + echo Enabling ICU support + # Try pkg-config first so that static linking works. # If this succeeeds, we ignore the WITH_ICU directory. PKG_CHECK_MODULES([ICU], [icu-i18n], [ From 6f2a597383194cc60485d363b1fe22fbb83a9273 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 20:37:03 +0200 Subject: [PATCH 475/504] build: Don't check for uint32_t --- config.h.cmake.in | 9 --------- configure.ac | 5 ----- meson.build | 2 -- 3 files changed, 16 deletions(-) diff --git a/config.h.cmake.in b/config.h.cmake.in index 811e58875..e28b6258f 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -107,12 +107,3 @@ /* TLS specifier */ #cmakedefine XML_THREAD_LOCAL @XML_THREAD_LOCAL@ - -/* Define for Solaris 2.5.1 so the uint32_t typedef from , - , or is not used. If the typedef were allowed, the - #define below would cause a syntax error. */ -#cmakedefine _UINT32_T @_UINT32_T@ - -/* Define to the type of an unsigned integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -#cmakedefine uint32_t @uint32_t@ diff --git a/configure.ac b/configure.ac index cba3c7c3a..4a594b524 100644 --- a/configure.ac +++ b/configure.ac @@ -312,11 +312,6 @@ AC_CHECK_HEADERS([dl.h dlfcn.h]) AC_CHECK_HEADERS([glob.h]) AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_header_glob_h" = "yes") -dnl -dnl Checking types -dnl -AC_TYPE_UINT32_T - dnl Checks for library functions. AC_CHECK_FUNCS([getentropy gettimeofday ftime isascii stat mmap munmap]) diff --git a/meson.build b/meson.build index 0f2bfbe61..c9534d801 100644 --- a/meson.build +++ b/meson.build @@ -50,8 +50,6 @@ endif # binaries cc = meson.get_compiler('c') -cc.has_type('uint32_t', prefix: '#include ') - # options want_c14n = get_option('c14n') want_catalog = get_option('catalog') From 11ce63f02b0d06bfbefdacf958cde6676dc22a7b Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 20:38:52 +0200 Subject: [PATCH 476/504] build: Don't check for isascii --- CMakeLists.txt | 1 - config.h.cmake.in | 3 --- configure.ac | 2 +- meson.build | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 613f0ab3b..723e23442 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,6 @@ if (NOT MSVC) check_function_exists(ftime HAVE_FTIME) check_function_exists(getentropy HAVE_GETENTROPY) check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) - check_function_exists(isascii HAVE_ISASCII) check_library_exists(history append_history "" HAVE_LIBHISTORY) check_library_exists(readline readline "" HAVE_LIBREADLINE) check_function_exists(mmap HAVE_MMAP) diff --git a/config.h.cmake.in b/config.h.cmake.in index e28b6258f..2f4aeba3b 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -28,9 +28,6 @@ /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine HAVE_GETTIMEOFDAY 1 -/* Define to 1 if you have the `isascii' function. */ -#cmakedefine HAVE_ISASCII 1 - /* Define if history library is there (-lhistory) */ #cmakedefine HAVE_LIBHISTORY 1 diff --git a/configure.ac b/configure.ac index 4a594b524..270e3635f 100644 --- a/configure.ac +++ b/configure.ac @@ -313,7 +313,7 @@ AC_CHECK_HEADERS([glob.h]) AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_header_glob_h" = "yes") dnl Checks for library functions. -AC_CHECK_FUNCS([getentropy gettimeofday ftime isascii stat mmap munmap]) +AC_CHECK_FUNCS([getentropy gettimeofday ftime stat mmap munmap]) AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */ #if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP) diff --git a/meson.build b/meson.build index c9534d801..d0d631d98 100644 --- a/meson.build +++ b/meson.build @@ -331,7 +331,6 @@ xml_check_functions = [ ['gettimeofday', 'sys/time.h'], ['ftime', 'sys/timeb.h'], ['stat', 'sys/stat.h'], - ['isascii', 'ctype.h'], ['mmap', 'sys/mman.h'], ['munmap', 'sys/mman.h'], ] From f524993e70d06dfc0d047292a891b9c9aecb05e3 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 20:56:55 +0200 Subject: [PATCH 477/504] build: Clean up configuration options Remove run-debug from meson. Fix documentation. --- README.md | 3 +-- configure.ac | 2 +- meson.build | 3 --- meson_options.txt | 7 ------- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 664bd3714..58c9433f9 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The following options disable or enable code modules and relevant symbols: --with-history history support for shell (off) --with-readline[=DIR] use readline in DIR (for shell history) --with-html HTML parser (on) - --with-http HTTP support (on) + --with-http HTTP support (off) --with-iconv[=DIR] iconv support (on) --with-icu ICU support (off) --with-iso8859x ISO-8859-X support if no iconv (on) @@ -61,7 +61,6 @@ The following options disable or enable code modules and relevant symbols: --with-python Python bindings (on) --with-reader xmlReader parsing interface (on) --with-regexps regular expressions support (on) - --with-run-debug runtime debugging module (off) --with-sax1 older SAX1 interface (on) --with-schemas XML Schemas 1.0 and RELAX NG support (on) --with-schematron Schematron support (on) diff --git a/configure.ac b/configure.ac index 270e3635f..cb90a262b 100644 --- a/configure.ac +++ b/configure.ac @@ -78,7 +78,7 @@ AC_ARG_WITH(readline, AC_ARG_WITH(html, [ --with-html HTML parser (on)]) AC_ARG_WITH(http, -[ --with-http HTTP support (on)]) +[ --with-http HTTP support (off)]) AC_ARG_WITH(iconv, [ --with-iconv[[=DIR]] iconv support (on)]) AC_ARG_WITH(icu, diff --git a/meson.build b/meson.build index d0d631d98..df626c6c5 100644 --- a/meson.build +++ b/meson.build @@ -73,7 +73,6 @@ want_python = get_option('python') want_reader = get_option('reader') want_readline = get_option('readline') want_regexps = get_option('regexps') -want_run_debug = get_option('run-debug') want_sax1 = get_option('sax1') want_schemas = get_option('schemas') want_schematron = get_option('schematron') @@ -198,7 +197,6 @@ if get_option('minimum') want_reader = false want_readline = false want_regexps = false - want_run_debug = false want_sax1 = false want_schemas = false want_schematron = false @@ -846,7 +844,6 @@ summary( 'reader': want_reader, 'readline': want_readline, 'regexps': want_regexps, - 'run-debug': want_run_debug, 'sax1': want_sax1, 'schemas': want_schemas, 'schematron': want_schematron, diff --git a/meson_options.txt b/meson_options.txt index 9c54df3a7..8a50665bf 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -22,7 +22,6 @@ # [X] reader # [X] readline # [X] regexps -# [ ] run-debug - not used # [X] sax1 # [X] schemas # [X] schematron @@ -176,12 +175,6 @@ option('regexps', description: 'Regular expressions support' ) -option('run-debug', - type: 'boolean', - value: false, - description: 'Runtime debugging module' -) - option('sax1', type: 'boolean', value: true, From e349709ae7e07a2183304ccc9352b6ac86f62a18 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 21 May 2024 21:07:16 +0200 Subject: [PATCH 478/504] build: Remove --with-fexceptions configuration option --- configure.ac | 12 ------------ meson.build | 7 ------- meson_options.txt | 7 ------- 3 files changed, 26 deletions(-) diff --git a/configure.ac b/configure.ac index cb90a262b..61520f4d8 100644 --- a/configure.ac +++ b/configure.ac @@ -135,8 +135,6 @@ AC_ARG_WITH(legacy, AC_ARG_WITH(tls, [ --with-tls thread-local storage (off)]) -AC_ARG_WITH(fexceptions, -[ --with-fexceptions add GCC flag -fexceptions for C++ exceptions (off)]) dnl dnl Legacy defaults @@ -237,7 +235,6 @@ if test "$with_minimum" = "yes"; then test "$with_c14n" = "" && with_c14n=no test "$with_catalog" = "" && with_catalog=no test "$with_debug" = "" && with_debug=no - test "$with_fexceptions" = "" && with_fexceptions=no test "$with_history" = "" && with_history=no test "$with_html" = "" && with_html=no test "$with_http" = "" && with_http=no @@ -479,15 +476,6 @@ if test "${GCC}" != "yes" ; then ;; esac else - if test "$with_fexceptions" = "yes" - then - # - # Not activated by default because this inflates the code size - # Used to allow propagation of C++ exceptions through the library - # - AM_CFLAGS="${AM_CFLAGS} -fexceptions" - fi - # warnings we'd like to see AM_CFLAGS="${AM_CFLAGS} -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes" # warnings we'd like to suppress diff --git a/meson.build b/meson.build index df626c6c5..95936a2cf 100644 --- a/meson.build +++ b/meson.build @@ -54,7 +54,6 @@ cc = meson.get_compiler('c') want_c14n = get_option('c14n') want_catalog = get_option('catalog') want_debug = get_option('debuging') -want_fexceptions = get_option('fexceptions') want_ftp = get_option('ftp') want_history = get_option('history') want_html = get_option('html') @@ -181,7 +180,6 @@ if get_option('minimum') want_c14n = false want_catalog = false want_debug = false - want_fexceptions = false want_history = false want_html = false want_http = false @@ -254,10 +252,6 @@ if cc.get_argument_syntax() == 'gcc' '-Wno-format-extra-args', ] - if want_fexceptions == true - cflags_try += '-fexceptions' - endif - if host_machine.cpu_family() == 'alpha' cflags_try += '-mieee' endif @@ -825,7 +819,6 @@ summary( 'c14n': want_c14n, 'catalog': want_catalog, 'debug': want_debug, - 'fexceptions': want_fexceptions, 'ftp': want_ftp, 'history': want_history, 'html': want_html, diff --git a/meson_options.txt b/meson_options.txt index 8a50665bf..7b4ba08dd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,7 +3,6 @@ # [X] c14n # [X] catalog # [X] debugging -# [X] fexceptions # [X] ftp - not minimum # [X] history # [X] html @@ -60,12 +59,6 @@ option('debuging', description: 'Debugging module and shell' ) -option('fexceptions', - type: 'boolean', - value: false, - description: 'add GCC flag -fexceptions for C++ exceptions' -) - option('ftp', type: 'boolean', value: false, From b7f30bae7b4e842ab66c8c8b3ba4a0daafd2d673 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 28 May 2024 22:26:18 +0200 Subject: [PATCH 479/504] fuzz: Fix aarch64 build on OSS-Fuzz --- fuzz/oss-fuzz-build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fuzz/oss-fuzz-build.sh b/fuzz/oss-fuzz-build.sh index 151255bfb..3e8945fc4 100755 --- a/fuzz/oss-fuzz-build.sh +++ b/fuzz/oss-fuzz-build.sh @@ -18,6 +18,12 @@ else CONFIG='--with-zlib --with-lzma' fi +# Workaround for a LeakSanitizer crashes, +# see https://github.com/google/oss-fuzz/issues/11798. +if [ "$ARCHITECTURE" = "aarch64" ]; then + export ASAN_OPTIONS=detect_leaks=0 +fi + export V=1 ./autogen.sh \ From ec09909dd3d075145cb1f5a764b4c0b02d79b309 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 29 May 2024 13:47:37 +0200 Subject: [PATCH 480/504] autotools: Fix pthread detection on FreeBSD pthread_join is defined by libc, so check for pthread_create instead. Should fix #725. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 61520f4d8..826abda7d 100644 --- a/configure.ac +++ b/configure.ac @@ -806,10 +806,10 @@ else dnl Use pthread by default in other cases _libs=$LIBS AC_CHECK_HEADERS(pthread.h, - AC_SEARCH_LIBS([pthread_join], [pthread], [ + AC_SEARCH_LIBS([pthread_create], [pthread], [ WITH_THREADS="1" - if test "$ac_cv_search_pthread_join" != "none required"; then - THREAD_LIBS=$ac_cv_search_pthread_join + if test "$ac_cv_search_pthread_create" != "none required"; then + THREAD_LIBS=$ac_cv_search_pthread_create fi AC_DEFINE([HAVE_PTHREAD_H], [], [Define if is there])])) From 11cd18d879efa604d5832d341d8a7dfab1a668ce Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 31 May 2024 13:31:09 +0200 Subject: [PATCH 481/504] valid: Check return value of xmlValidBuildAContentModel Fixes return code in case of malloc failure. --- valid.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/valid.c b/valid.c index c3c7ee179..1b711e649 100644 --- a/valid.c +++ b/valid.c @@ -512,11 +512,13 @@ xmlValidBuildAContentModel(xmlElementContentPtr content, oldstate = ctxt->state; } do { - xmlValidBuildAContentModel(content->c1, ctxt, name); + if (xmlValidBuildAContentModel(content->c1, ctxt, name) == 0) + return(0); content = content->c2; } while ((content->type == XML_ELEMENT_CONTENT_SEQ) && (content->ocur == XML_ELEMENT_CONTENT_ONCE)); - xmlValidBuildAContentModel(content, ctxt, name); + if (xmlValidBuildAContentModel(content, ctxt, name) == 0) + return(0); oldend = ctxt->state; ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldend, NULL); switch (ocur) { @@ -554,13 +556,15 @@ xmlValidBuildAContentModel(xmlElementContentPtr content, */ do { ctxt->state = oldstate; - xmlValidBuildAContentModel(content->c1, ctxt, name); + if (xmlValidBuildAContentModel(content->c1, ctxt, name) == 0) + return(0); xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldend); content = content->c2; } while ((content->type == XML_ELEMENT_CONTENT_OR) && (content->ocur == XML_ELEMENT_CONTENT_ONCE)); ctxt->state = oldstate; - xmlValidBuildAContentModel(content, ctxt, name); + if (xmlValidBuildAContentModel(content, ctxt, name) == 0) + return(0); xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldend); ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldend, NULL); switch (ocur) { @@ -624,7 +628,8 @@ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) { return(0); } ctxt->state = xmlAutomataGetInitState(ctxt->am); - xmlValidBuildAContentModel(elem->content, ctxt, elem->name); + if (xmlValidBuildAContentModel(elem->content, ctxt, elem->name) == 0) + goto done; xmlAutomataSetFinalState(ctxt->am, ctxt->state); elem->contModel = xmlAutomataCompile(ctxt->am); if (elem->contModel == NULL) { From 5198de4b1d273026310428351b9ebd1f784e3927 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 31 May 2024 13:42:08 +0200 Subject: [PATCH 482/504] fuzz: Make allocation in xmlBuildQName more likely Limit size of static buffer in fuzzing mode. --- tree.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tree.c b/tree.c index 4202d717d..75f7569a3 100644 --- a/tree.c +++ b/tree.c @@ -173,6 +173,12 @@ xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, if (ncname == NULL) return(NULL); if (prefix == NULL) return((xmlChar *) ncname); +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Make allocation more likely */ + if (len > 8) + len = 8; +#endif + lenn = strlen((char *) ncname); lenp = strlen((char *) prefix); From f0d891585d63e380bf45044d4b5e535dc610871a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 1 Jun 2024 15:41:43 +0200 Subject: [PATCH 483/504] entities: Unconst predefined entities Partial revert of commit 63ce5f9a. For some reason, Chromium and WebKit set the etype member of predefined entities. This should be fixed first. --- entities.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/entities.c b/entities.c index 28e2481c1..1d033cbf6 100644 --- a/entities.c +++ b/entities.c @@ -33,35 +33,35 @@ * The XML predefined entities. */ -static const xmlEntity xmlEntityLt = { +static xmlEntity xmlEntityLt = { NULL, XML_ENTITY_DECL, BAD_CAST "lt", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "<", BAD_CAST "<", 1, XML_INTERNAL_PREDEFINED_ENTITY, NULL, NULL, NULL, NULL, 0, 0, 0 }; -static const xmlEntity xmlEntityGt = { +static xmlEntity xmlEntityGt = { NULL, XML_ENTITY_DECL, BAD_CAST "gt", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST ">", BAD_CAST ">", 1, XML_INTERNAL_PREDEFINED_ENTITY, NULL, NULL, NULL, NULL, 0, 0, 0 }; -static const xmlEntity xmlEntityAmp = { +static xmlEntity xmlEntityAmp = { NULL, XML_ENTITY_DECL, BAD_CAST "amp", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "&", BAD_CAST "&", 1, XML_INTERNAL_PREDEFINED_ENTITY, NULL, NULL, NULL, NULL, 0, 0, 0 }; -static const xmlEntity xmlEntityQuot = { +static xmlEntity xmlEntityQuot = { NULL, XML_ENTITY_DECL, BAD_CAST "quot", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "\"", BAD_CAST "\"", 1, XML_INTERNAL_PREDEFINED_ENTITY, NULL, NULL, NULL, NULL, 0, 0, 0 }; -static const xmlEntity xmlEntityApos = { +static xmlEntity xmlEntityApos = { NULL, XML_ENTITY_DECL, BAD_CAST "apos", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "'", BAD_CAST "'", 1, @@ -308,21 +308,21 @@ xmlGetPredefinedEntity(const xmlChar *name) { switch (name[0]) { case 'l': if (xmlStrEqual(name, BAD_CAST "lt")) - return((xmlEntityPtr) &xmlEntityLt); + return(&xmlEntityLt); break; case 'g': if (xmlStrEqual(name, BAD_CAST "gt")) - return((xmlEntityPtr) &xmlEntityGt); + return(&xmlEntityGt); break; case 'a': if (xmlStrEqual(name, BAD_CAST "amp")) - return((xmlEntityPtr) &xmlEntityAmp); + return(&xmlEntityAmp); if (xmlStrEqual(name, BAD_CAST "apos")) - return((xmlEntityPtr) &xmlEntityApos); + return(&xmlEntityApos); break; case 'q': if (xmlStrEqual(name, BAD_CAST "quot")) - return((xmlEntityPtr) &xmlEntityQuot); + return(&xmlEntityQuot); break; default: break; From a7e26707be674ef60044fe3dddd3c8afcc450136 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Mon, 3 Jun 2024 14:04:44 +0200 Subject: [PATCH 484/504] parser: Don't overwrite OOM errors in xmlSBuf --- parser.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/parser.c b/parser.c index d550b1b63..8b8cf8b8d 100644 --- a/parser.c +++ b/parser.c @@ -739,7 +739,8 @@ xmlSBufGrow(xmlSBuf *buf, unsigned len) { unsigned cap; if (len >= UINT_MAX / 2 - buf->size) { - buf->code = XML_ERR_RESOURCE_LIMIT; + if (buf->code == XML_ERR_OK) + buf->code = XML_ERR_RESOURCE_LIMIT; return(-1); } @@ -762,7 +763,8 @@ xmlSBufGrow(xmlSBuf *buf, unsigned len) { static void xmlSBufAddString(xmlSBuf *buf, const xmlChar *str, unsigned len) { if (buf->max - buf->size < len) { - buf->code = XML_ERR_RESOURCE_LIMIT; + if (buf->code == XML_ERR_OK) + buf->code = XML_ERR_RESOURCE_LIMIT; return; } @@ -786,7 +788,8 @@ xmlSBufAddChar(xmlSBuf *buf, int c) { xmlChar *end; if (buf->max - buf->size < 4) { - buf->code = XML_ERR_RESOURCE_LIMIT; + if (buf->code == XML_ERR_OK) + buf->code = XML_ERR_RESOURCE_LIMIT; return; } From 0160127fda8f45e4b0c37eea71513105db67e0ac Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 1 May 2024 13:07:52 -0700 Subject: [PATCH 485/504] meson: fix usage as a subproject include directories must be passed to that projects can use headers. Also add override_dependencies to make sure that it's used when available as a subproject. Signed-off-by: Rosen Penev --- meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 95936a2cf..0c4f7eab4 100644 --- a/meson.build +++ b/meson.build @@ -699,7 +699,10 @@ xml_lib = library( version: meson.project_version(), ) -xml_dep = declare_dependency(link_with: xml_lib) +dep_inc = include_directories('include') +xml_dep = declare_dependency(include_directories: dep_inc, link_with: xml_lib) + +meson.override_dependency('libxml-2.0', xml_dep) ## xmllint tool From 4b2f250a5b883b0fad8a351d36d4cdef41396061 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 3 May 2024 13:11:47 -0700 Subject: [PATCH 486/504] meson: don't use dl dependency on old meson dl dependency was introduced with version 0.62. Signed-off-by: Rosen Penev --- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 0c4f7eab4..ff17ae269 100644 --- a/meson.build +++ b/meson.build @@ -412,7 +412,11 @@ if want_modules == true endif if with_modules == false - dl_dep = dependency('dl', required: false) + if meson.version().version_compare('>=0.62') + dl_dep = dependency('dl', required: false) + else + dl_dep = cc.find_library('dl', required: false) + endif if dl_dep.found() config_h.set10('HAVE_DLOPEN', true) xml_deps += dl_dep From 16d914a9f370b3eaae5d30ae53c2f323575977fa Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 3 Jun 2024 17:09:17 -0700 Subject: [PATCH 487/504] meson: fix compilation with local binaries threads_dep is needed for runtest. Signed-off-by: Rosen Penev --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ff17ae269..43d93343e 100644 --- a/meson.build +++ b/meson.build @@ -435,6 +435,8 @@ if want_threads == true else want_threads = false endif + else + threads_dep = dependency('', required: false) endif endif @@ -759,7 +761,7 @@ foreach check : checks exe = executable( check, files(check + '.c'), - dependencies: xml_dep, + dependencies: [threads_dep, xml_dep], include_directories: config_dir, ) if check != 'testlimits' From 897c73fe24e7031d84e090951c81103827da5b55 Mon Sep 17 00:00:00 2001 From: Sadaf Ebrahimi Date: Wed, 5 Jun 2024 17:43:32 +0000 Subject: [PATCH 488/504] Add missing _cplusplus processing clause --- include/libxml/xmlexports.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/libxml/xmlexports.h b/include/libxml/xmlexports.h index 3d90a7e42..99f9c37b2 100644 --- a/include/libxml/xmlexports.h +++ b/include/libxml/xmlexports.h @@ -128,8 +128,17 @@ /* * Originally declared in xmlversion.h which is generated */ + +#ifdef __cplusplus +extern "C" { +#endif + XMLPUBFUN void xmlCheckVersion(int version); +#ifdef __cplusplus +} +#endif + #endif /* __XML_EXPORTS_H__ */ From 122b61309f090e5d81c3ca083aaf28c0398a171a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 4 Jun 2024 16:33:02 +0200 Subject: [PATCH 489/504] parser: Fix performance regression when parsing namespaces The namespace hash table didn't reuse deleted buckets, leading to quadratic behavior. Also ignore deleted buckets when resizing. Fixes #726. --- parser.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/parser.c b/parser.c index 8b8cf8b8d..486bfa293 100644 --- a/parser.c +++ b/parser.c @@ -1525,7 +1525,7 @@ xmlParserNsStartElement(xmlParserNsData *nsdb) { static int xmlParserNsLookup(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix, xmlParserNsBucket **bucketPtr) { - xmlParserNsBucket *bucket; + xmlParserNsBucket *bucket, *tombstone; unsigned index, hashValue; if (prefix->name == NULL) @@ -1537,10 +1537,13 @@ xmlParserNsLookup(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix, hashValue = prefix->hashValue; index = hashValue & (ctxt->nsdb->hashSize - 1); bucket = &ctxt->nsdb->hash[index]; + tombstone = NULL; while (bucket->hashValue) { - if ((bucket->hashValue == hashValue) && - (bucket->index != INT_MAX)) { + if (bucket->index == INT_MAX) { + if (tombstone == NULL) + tombstone = bucket; + } else if (bucket->hashValue == hashValue) { if (ctxt->nsTab[bucket->index * 2] == prefix->name) { if (bucketPtr != NULL) *bucketPtr = bucket; @@ -1557,7 +1560,7 @@ xmlParserNsLookup(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix, } if (bucketPtr != NULL) - *bucketPtr = bucket; + *bucketPtr = tombstone ? tombstone : bucket; return(INT_MAX); } @@ -1798,7 +1801,7 @@ xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix, unsigned hv = ctxt->nsdb->hash[i].hashValue; unsigned newIndex; - if (hv == 0) + if ((hv == 0) || (ctxt->nsdb->hash[i].index == INT_MAX)) continue; newIndex = hv & (newSize - 1); From e2919516bc85eaa672995e94c90911b8bf4a75fa Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 6 Jun 2024 19:28:23 +0200 Subject: [PATCH 490/504] xmllint: Fix build --with-valid --without-html --- xmllint.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xmllint.c b/xmllint.c index 4cf865b1d..3a7a8a002 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2448,7 +2448,11 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { #endif /* LIBXML_TREE_ENABLED */ #ifdef LIBXML_VALID_ENABLED - if ((insert) && (!html)) { + if ((insert) +#ifdef LIBXML_HTML_ENABLED + && (!html) +#endif + ) { const xmlChar* list[256]; int nb, i; xmlNodePtr node; @@ -2620,7 +2624,7 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { else if (format == 2) saveOpts |= XML_SAVE_WSNONSIG; -#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) +#if defined(LIBXML_HTML_ENABLED) if (xmlout) saveOpts |= XML_SAVE_AS_XML; #endif @@ -2855,10 +2859,12 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) { #endif #ifdef LIBXML_DEBUG_ENABLED -#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) - if ((debugent) && (!html)) - xmlDebugDumpEntities(ERR_STREAM, doc); + if ((debugent) +#if defined(LIBXML_HTML_ENABLED) + && (!html) #endif + ) + xmlDebugDumpEntities(ERR_STREAM, doc); #endif /* From 15ed75664bd6e5dd0530419139558b7f1b670637 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 6 Jun 2024 22:18:05 +0200 Subject: [PATCH 491/504] xinclude: Fix warning when building --without-xptr --- xinclude.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xinclude.c b/xinclude.c index 1a54f7c24..7949a1c36 100644 --- a/xinclude.c +++ b/xinclude.c @@ -1017,6 +1017,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlXPathObjectPtr range) { } #endif /* LIBXML_XPTR_LOCS_ENABLED */ +#ifdef LIBXML_XPTR_ENABLED /** * xmlXIncludeCopyXPointer: * @ctxt: the XInclude context @@ -1127,6 +1128,8 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlXPathObjectPtr obj, } return(list); } +#endif + /************************************************************************ * * * XInclude I/O handling * From 1ae68e40df27d40471074f9b454096e4e4209ca4 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 6 Jun 2024 22:55:15 +0200 Subject: [PATCH 492/504] python: Fix build with disabled modules --- python/libxml.c | 14 ++++++++++++++ python/libxml_wrap.h | 12 ++++++++++-- python/types.c | 18 +++++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/python/libxml.c b/python/libxml.c index 681091e34..7c0f27fc0 100644 --- a/python/libxml.c +++ b/python/libxml.c @@ -50,6 +50,8 @@ void initlibxml2mod(void); xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); + +#ifdef LIBXML_XPATH_ENABLED /* * the following vars are used for XPath extensions, but * are also referenced within the parser cleanup routine. @@ -66,6 +68,7 @@ typedef libxml_xpathCallback libxml_xpathCallbackArray[]; static int libxml_xpathCallbacksAllocd = 10; static libxml_xpathCallbackArray *libxml_xpathCallbacks = NULL; static int libxml_xpathCallbacksNb = 0; +#endif /* LIBXML_XPATH_ENABLED */ /************************************************************************ * * @@ -160,6 +163,7 @@ PyObject * libxml_xmlPythonCleanupParser(PyObject *self ATTRIBUTE_UNUSED, PyObject *args ATTRIBUTE_UNUSED) { +#ifdef LIBXML_XPATH_ENABLED int ix; /* @@ -178,6 +182,7 @@ libxml_xmlPythonCleanupParser(PyObject *self ATTRIBUTE_UNUSED, xmlFree(libxml_xpathCallbacks); libxml_xpathCallbacks = NULL; } +#endif /* LIBXML_XPATH_ENABLED */ xmlCleanupParser(); @@ -1327,6 +1332,7 @@ static xmlSAXHandler pythonSaxHandler = { * * ************************************************************************/ +#ifdef LIBXML_PUSH_ENABLED PyObject * libxml_xmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) @@ -1383,6 +1389,7 @@ libxml_htmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self, return (pyret); } #endif /* LIBXML_HTML_ENABLED */ +#endif /* LIBXML_PUSH_ENABLED */ #ifdef LIBXML_SAX1_ENABLED PyObject * @@ -2062,6 +2069,7 @@ libxml_xmlFreeTextReader(ATTRIBUTE_UNUSED PyObject *self, PyObject *args) { * * ************************************************************************/ +#ifdef LIBXML_XPATH_ENABLED static void libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs) { @@ -2236,6 +2244,7 @@ libxml_xmlXPathRegisterVariable(ATTRIBUTE_UNUSED PyObject * self, py_retval = libxml_intWrap(c_retval); return (py_retval); } +#endif /* LIBXML_XPATH_ENABLED */ /************************************************************************ * * @@ -2876,6 +2885,8 @@ libxml_xmlNewNode(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) * Local Catalog stuff * * * ************************************************************************/ + +#ifdef LIBXML_CATALOG_ENABLED static PyObject * libxml_addLocalCatalog(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) { @@ -2895,6 +2906,7 @@ libxml_addLocalCatalog(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) Py_INCREF(Py_None); return (Py_None); } +#endif /* LIBXML_CATALOG_ENABLED */ #ifdef LIBXML_SCHEMAS_ENABLED @@ -3611,7 +3623,9 @@ static PyMethodDef libxmlMethods[] = { {(char *)"xmlTextReaderGetErrorHandler", libxml_xmlTextReaderGetErrorHandler, METH_VARARGS, NULL }, {(char *)"xmlFreeTextReader", libxml_xmlFreeTextReader, METH_VARARGS, NULL }, #endif +#ifdef LIBXML_CATALOG_ENABLED {(char *)"addLocalCatalog", libxml_addLocalCatalog, METH_VARARGS, NULL }, +#endif #ifdef LIBXML_SCHEMAS_ENABLED {(char *)"xmlRelaxNGSetValidErrors", libxml_xmlRelaxNGSetValidErrors, METH_VARARGS, NULL}, {(char *)"xmlRelaxNGFreeValidCtxt", libxml_xmlRelaxNGFreeValidCtxt, METH_VARARGS, NULL}, diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h index d13c59643..e9cc6e3ef 100644 --- a/python/libxml_wrap.h +++ b/python/libxml_wrap.h @@ -89,6 +89,7 @@ typedef struct { xmlNodePtr obj; } PyxmlNode_Object; +#ifdef LIBXML_XPATH_ENABLED #define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \ (((PyxmlXPathContext_Object *)(v))->obj)) @@ -104,6 +105,7 @@ typedef struct { PyObject_HEAD xmlXPathParserContextPtr obj; } PyxmlXPathParserContext_Object; +#endif /* LIBXML_XPATH_ENABLED */ #define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \ (((PyparserCtxt_Object *)(v))->obj)) @@ -121,6 +123,7 @@ typedef struct { xmlValidCtxtPtr obj; } PyValidCtxt_Object; +#ifdef LIBXML_CATALOG_ENABLED #define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \ (((Pycatalog_Object *)(v))->obj)) @@ -128,6 +131,7 @@ typedef struct { PyObject_HEAD xmlCatalogPtr obj; } Pycatalog_Object; +#endif /* LIBXML_CATALOG_ENABLED */ #ifdef LIBXML_REGEXP_ENABLED #define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \ @@ -267,12 +271,17 @@ PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns); PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns); PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns); PyObject * libxml_doubleWrap(double val); -PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt); PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt); +#ifdef LIBXML_XPATH_ENABLED +PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt); PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt); PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj); +xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj); +#endif PyObject * libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid); +#ifdef LIBXML_CATALOG_ENABLED PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj); +#endif PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri); PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer); PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer); @@ -284,7 +293,6 @@ PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader); PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator); #endif -xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj); #ifdef LIBXML_SCHEMAS_ENABLED PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt); PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt); diff --git a/python/types.c b/python/types.c index 2782a6aae..480c925bd 100644 --- a/python/types.c +++ b/python/types.c @@ -425,7 +425,7 @@ libxml_xmlElementPtrWrap(xmlElementPtr elem) } PyObject * -libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt) +libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) { PyObject *ret; @@ -433,12 +433,14 @@ libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt) Py_INCREF(Py_None); return (Py_None); } - ret = PyCapsule_New((void *) ctxt, (char *) "xmlXPathContextPtr", NULL); + + ret = PyCapsule_New((void *) ctxt, (char *) "xmlParserCtxtPtr", NULL); return (ret); } +#ifdef LIBXML_XPATH_ENABLED PyObject * -libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt) +libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt) { PyObject *ret; @@ -446,12 +448,12 @@ libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt) Py_INCREF(Py_None); return (Py_None); } - ret = PyCapsule_New((void *)ctxt, (char *)"xmlXPathParserContextPtr", NULL); + ret = PyCapsule_New((void *) ctxt, (char *) "xmlXPathContextPtr", NULL); return (ret); } PyObject * -libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) +libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt) { PyObject *ret; @@ -459,8 +461,7 @@ libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) Py_INCREF(Py_None); return (Py_None); } - - ret = PyCapsule_New((void *) ctxt, (char *) "xmlParserCtxtPtr", NULL); + ret = PyCapsule_New((void *)ctxt, (char *)"xmlXPathParserContextPtr", NULL); return (ret); } @@ -758,6 +759,7 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj) } return (ret); } +#endif /* LIBXML_XPATH_ENABLED */ PyObject * libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid) @@ -776,6 +778,7 @@ libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid) return (ret); } +#ifdef LIBXML_CATALOG_ENABLED PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal) { @@ -790,6 +793,7 @@ libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal) (char *) "xmlCatalogPtr", NULL); return (ret); } +#endif /* LIBXML_CATALOG_ENABLED */ PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer) From 0d0cb4c2bdeac8954337ec1d5881c0b709b6677a Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 6 Jun 2024 23:07:16 +0200 Subject: [PATCH 493/504] runtest: Check for IBM-1141 encoding handler Should fix #729. --- runtest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtest.c b/runtest.c index 4ee8182e2..ab8050ffe 100644 --- a/runtest.c +++ b/runtest.c @@ -4932,9 +4932,10 @@ launchTests(testDescPtr tst) { char *result; char *error; int mem; - xmlCharEncodingHandlerPtr ebcdicHandler, eucJpHandler; + xmlCharEncodingHandlerPtr ebcdicHandler, ibm1141Handler, eucJpHandler; ebcdicHandler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EBCDIC); + ibm1141Handler = xmlFindCharEncodingHandler("IBM-1141"); eucJpHandler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EUC_JP); if (tst == NULL) return(-1); @@ -4946,7 +4947,7 @@ launchTests(testDescPtr tst) { for (i = 0;i < globbuf.gl_pathc;i++) { if (!checkTestFile(globbuf.gl_pathv[i])) continue; - if (((ebcdicHandler == NULL) && + if ((((ebcdicHandler == NULL) || (ibm1141Handler == NULL)) && (strstr(globbuf.gl_pathv[i], "ebcdic") != NULL)) || ((eucJpHandler == NULL) && (strstr(globbuf.gl_pathv[i], "icu_parse_test") != NULL))) @@ -5012,6 +5013,7 @@ launchTests(testDescPtr tst) { } xmlCharEncCloseFunc(ebcdicHandler); + xmlCharEncCloseFunc(ibm1141Handler); xmlCharEncCloseFunc(eucJpHandler); return(err); From 02cbb2b64f901c3737c8cb8241e2734c3cc57a13 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 6 Jun 2024 23:09:17 +0200 Subject: [PATCH 494/504] runtest: Suppress undeclared entity errors --- runtest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtest.c b/runtest.c index ab8050ffe..f4ead885a 100644 --- a/runtest.c +++ b/runtest.c @@ -2131,7 +2131,8 @@ noentParseTest(const char *filename, const char *result, /* * base of the test, parse with the old API */ - doc = xmlReadFile(filename, NULL, options | XML_PARSE_NOWARNING); + doc = xmlReadFile(filename, NULL, + options | XML_PARSE_NOWARNING | XML_PARSE_NOERROR); if (doc == NULL) return(1); temp = resultFilename(filename, temp_directory, ".res"); @@ -2148,7 +2149,8 @@ noentParseTest(const char *filename, const char *result, /* * Parse the saved result to make sure the round trip is okay */ - doc = xmlReadFile(filename, NULL, options | XML_PARSE_NOWARNING); + doc = xmlReadFile(filename, NULL, + options | XML_PARSE_NOWARNING | XML_PARSE_NOERROR); if (doc == NULL) return(1); xmlSaveFile(temp, doc); From 0cde1b78d6d97ae6b89f3170c8731261a21efcf6 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 6 Jun 2024 23:50:03 +0200 Subject: [PATCH 495/504] parser: Fix "Truncated multi-byte sequence" error Don't raise the error if decoding failed. --- parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parser.c b/parser.c index 486bfa293..832229c1f 100644 --- a/parser.c +++ b/parser.c @@ -10584,6 +10584,7 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL); } else if ((ctxt->input->buf != NULL) && (ctxt->input->buf->encoder != NULL) && + (ctxt->input->buf->error == 0) && (!xmlBufIsEmpty(ctxt->input->buf->raw))) { xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR, "Truncated multi-byte sequence at EOF\n"); @@ -11589,6 +11590,7 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size, } } else if ((ctxt->input->buf != NULL) && (ctxt->input->buf->encoder != NULL) && + (ctxt->input->buf->error == 0) && (!xmlBufIsEmpty(ctxt->input->buf->raw))) { xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR, "Truncated multi-byte sequence at EOF\n"); From afe8f8451459750d330e8bca9ee3b02aeadeebb5 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 7 Jun 2024 00:01:16 +0200 Subject: [PATCH 496/504] runtest: Work around broken EUC-JP support in musl iconv Should fix #728. --- runtest.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/runtest.c b/runtest.c index f4ead885a..26681a3c2 100644 --- a/runtest.c +++ b/runtest.c @@ -4938,7 +4938,25 @@ launchTests(testDescPtr tst) { ebcdicHandler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EBCDIC); ibm1141Handler = xmlFindCharEncodingHandler("IBM-1141"); + + /* + * When decoding EUC-JP, musl doesn't seem to support 0x8F control + * codes. + */ eucJpHandler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_EUC_JP); + if (eucJpHandler != NULL) { + xmlBufferPtr in, out; + + in = xmlBufferCreateSize(10); + xmlBufferCCat(in, "\x8f\xe9\xae"); + out = xmlBufferCreateSize(10); + if (xmlCharEncInFunc(eucJpHandler, out, in) != 3) { + xmlCharEncCloseFunc(eucJpHandler); + eucJpHandler = NULL; + } + xmlBufferFree(out); + xmlBufferFree(in); + } if (tst == NULL) return(-1); if (tst->in != NULL) { From ed3e53de0e979488b14b63c712eb4f54fe9ed4d1 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Thu, 6 Jun 2024 10:50:19 -0700 Subject: [PATCH 497/504] meson: Pass LIBXML_STATIC in dependency --- meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 43d93343e..39831b8a4 100644 --- a/meson.build +++ b/meson.build @@ -39,11 +39,13 @@ sys_windows = windows.contains(host_os) libxml2_cflags = [] xml_cflags = '' +dep_args = [] if sys_cygwin or sys_windows if get_option('default_library') == 'static' xml_cflags = '-DLIBXML_STATIC' libxml2_cflags += '-DLIBXML_STATIC' + dep_args += '-DLIBXML_STATIC' endif endif @@ -706,7 +708,7 @@ xml_lib = library( ) dep_inc = include_directories('include') -xml_dep = declare_dependency(include_directories: dep_inc, link_with: xml_lib) +xml_dep = declare_dependency(include_directories: dep_inc, link_with: xml_lib, compile_args: dep_args) meson.override_dependency('libxml-2.0', xml_dep) From f2270863807c4d7bd33f671a87b2438d605602ae Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 6 Jun 2024 13:42:03 -0700 Subject: [PATCH 498/504] meson: convert boolean options to feature option Simpler. Seems like they're only disabled by minimum. Signed-off-by: Rosen Penev --- include/libxml/meson.build | 12 ++-- meson.build | 138 +++++++++++++++---------------------- meson_options.txt | 18 ++--- python/meson.build | 10 +-- 4 files changed, 74 insertions(+), 104 deletions(-) diff --git a/include/libxml/meson.build b/include/libxml/meson.build index 4355e31cd..2b2cfb78a 100644 --- a/include/libxml/meson.build +++ b/include/libxml/meson.build @@ -10,12 +10,12 @@ xmlversion_h.set10('WITH_DEBUG', want_debug) xmlversion_h.set10('WITH_FTP', want_ftp) xmlversion_h.set10('WITH_HTML', want_html) xmlversion_h.set10('WITH_HTTP', want_http) -xmlversion_h.set10('WITH_ICONV', want_iconv) -xmlversion_h.set10('WITH_ICU', want_icu) +xmlversion_h.set10('WITH_ICONV', iconv_dep.found()) +xmlversion_h.set10('WITH_ICU', icu_dep.found()) xmlversion_h.set10('WITH_ISO8859X', want_iso8859x) xmlversion_h.set10('WITH_LEGACY', want_legacy) -xmlversion_h.set10('WITH_LZMA', want_lzma) -xmlversion_h.set10('WITH_MODULES', with_modules) +xmlversion_h.set10('WITH_LZMA', lzma_dep.found()) +xmlversion_h.set10('WITH_MODULES', dl_dep.found()) xmlversion_h.set('MODULE_EXTENSION', module_extension) xmlversion_h.set10('WITH_OUTPUT', want_output) xmlversion_h.set10('WITH_PATTERN', want_pattern) @@ -25,7 +25,7 @@ xmlversion_h.set10('WITH_REGEXPS', want_regexps) xmlversion_h.set10('WITH_SAX1', want_sax1) xmlversion_h.set10('WITH_SCHEMAS', want_schemas) xmlversion_h.set10('WITH_SCHEMATRON', want_schematron) -xmlversion_h.set10('WITH_THREADS', want_threads) +xmlversion_h.set10('WITH_THREADS', threads_dep.found()) xmlversion_h.set10('WITH_THREAD_ALLOC', want_thread_alloc) xmlversion_h.set10('WITH_TREE', want_tree) xmlversion_h.set10('WITH_VALID', want_valid) @@ -34,7 +34,7 @@ xmlversion_h.set10('WITH_XINCLUDE', want_xinclude) xmlversion_h.set10('WITH_XPATH', want_xpath) xmlversion_h.set10('WITH_XPTR', want_xptr) xmlversion_h.set10('WITH_XPTR_LOCS', want_xptr_locs) -xmlversion_h.set10('WITH_ZLIB', want_zlib) +xmlversion_h.set10('WITH_ZLIB', zlib_dep.found()) configure_file( input: 'xmlversion.h.in', diff --git a/meson.build b/meson.build index 39831b8a4..0542fe9a5 100644 --- a/meson.build +++ b/meson.build @@ -60,13 +60,9 @@ want_ftp = get_option('ftp') want_history = get_option('history') want_html = get_option('html') want_http = get_option('http') -want_iconv = get_option('iconv') -want_icu = get_option('icu') want_ipv6 = get_option('ipv6') want_iso8859x = get_option('iso8859x') want_legacy = get_option('legacy') -want_lzma = get_option('lzma') -want_modules = get_option('modules') want_output = get_option('output') want_pattern = get_option('pattern') want_push = get_option('push') @@ -77,7 +73,6 @@ want_regexps = get_option('regexps') want_sax1 = get_option('sax1') want_schemas = get_option('schemas') want_schematron = get_option('schematron') -want_threads = get_option('threads') want_thread_alloc = get_option('thread-alloc') want_tls = get_option('tls') want_tree = get_option('tree') @@ -87,7 +82,6 @@ want_xinclude = get_option('xinclude') want_xpath = get_option('xpath') want_xptr = get_option('xptr') want_xptr_locs = get_option('xptr-locs') -want_zlib = get_option('zlib') # TODO: Options should be three-valued: "yes", "no", default @@ -185,11 +179,8 @@ if get_option('minimum') want_history = false want_html = false want_http = false - want_iconv = false want_ipv6 = false want_iso8859x = false - want_lzma = false - want_modules = false want_output = false want_pattern = false want_push = false @@ -200,7 +191,6 @@ if get_option('minimum') want_sax1 = false want_schemas = false want_schematron = false - want_threads = false want_thread_alloc = false want_tree = false want_valid = false @@ -209,7 +199,6 @@ if get_option('minimum') want_xpath = false want_xptr = false want_xptr_locs = false - want_zlib = false else # Disable dependent modules if want_output == false @@ -402,49 +391,46 @@ if cc.has_function_attribute('destructor') endif ### DSO support -with_modules = false -if want_modules == true - if sys_cygwin == true - module_extension = '.dll' - elif sys_windows == true - module_extension = '.dll' - with_modules = true - else - module_extension = '.so' - endif +if sys_cygwin == true + module_extension = '.dll' +elif sys_windows == true + module_extension = '.dll' +else + module_extension = '.so' +endif - if with_modules == false +dl_dep = dependency('', required: false) +if not get_option('minimum') + if host_machine.system() != 'windows' if meson.version().version_compare('>=0.62') - dl_dep = dependency('dl', required: false) + dl_dep = dependency('dl', required: get_option('modules')) else - dl_dep = cc.find_library('dl', required: false) + dl_dep = cc.find_library('dl', required: get_option('modules')) endif if dl_dep.found() config_h.set10('HAVE_DLOPEN', true) xml_deps += dl_dep - with_modules = true endif + elif get_option('modules').allowed() + dl_dep = declare_dependency() endif endif ### threads -if want_threads == true - if sys_windows == false - threads_dep = dependency('threads') +threads_dep = dependency('', required: false) +if not get_option('minimum') + if host_machine.system() != 'windows' + threads_dep = dependency('threads', required: get_option('threads')) if threads_dep.found() config_h.set10('HAVE_PTHREAD_H', true) xml_deps += threads_dep - else - want_threads = false endif - else - threads_dep = dependency('', required: false) + elif get_option('threads').allowed() + threads_dep = declare_dependency() endif endif -want_thread_alloc = ( - (want_threads == true and want_threads == true) ? true : false -) +want_thread_alloc = threads_dep.found() ### xmllint shell history xmllint_deps = [] @@ -582,51 +568,41 @@ int main() endif ### zlib -if want_zlib == true - zlib_dep = dependency('zlib', required: false) - if zlib_dep.found() - xml_deps += zlib_dep - else - want_zlib = false - endif +if not get_option('minimum') + zlib_dep = dependency('zlib', required: get_option('zlib')) +else + zlib_dep = dependency('', required: false) endif +xml_deps += zlib_dep ### lzma -if want_lzma == true - lzma_dep = dependency('liblzma', required: false) - if lzma_dep.found() - xml_deps += lzma_dep - else - want_lzma = false - endif +if not get_option('minimum') + lzma_dep = dependency('liblzma', required: get_option('lzma')) +else + lzma_dep = dependency('', required: false) endif +xml_deps += lzma_dep ### iconv -if want_iconv == true - iconv_dep = dependency('iconv', required: false) - if iconv_dep.found() - xml_deps += iconv_dep - else - want_iconv = false - endif +if not get_option('minimum') + iconv_dep = dependency('iconv', required: get_option('iconv')) +else + iconv_dep = dependency('', required: false) endif +xml_deps += iconv_dep -if want_iconv == false and want_iso8859x == false +if not iconv_dep.found() and want_iso8859x == false want_iso8859x = false else want_iso8859x = true endif # icu -if want_icu == true - icu_dep = dependency('icu-i18n', method: 'pkg-config', required: false) - if icu_dep.found() - def_var = icu_dep.get_variable(pkgconfig: 'DEFS') - config_dir += include_directories(def_var) - xml_deps += icu_dep - else - want_icu = false - endif +icu_dep = dependency('icu-i18n', method: 'pkg-config', required: get_option('icu')) +if icu_dep.found() + def_var = icu_dep.get_variable(pkgconfig: 'DEFS') + config_dir += include_directories(def_var) + xml_deps += icu_dep endif subdir('include/libxml') @@ -667,8 +643,8 @@ xml_opt_src = [ [want_html, ['HTMLparser.c', 'HTMLtree.c']], [want_http, ['nanohttp.c']], [want_legacy, ['legacy.c']], - [want_lzma, ['xzlib.c']], - [with_modules, ['xmlmodule.c']], + [lzma_dep.found(), ['xzlib.c']], + [dl_dep.found(), ['xmlmodule.c']], [want_output, ['xmlsave.c']], [want_pattern, ['pattern.c']], [want_reader, ['xmlreader.c']], @@ -787,7 +763,7 @@ pkgmod.generate( description: 'libXML library version2.', filebase: 'libxml-2.0', name: 'libXML', - variables: 'modules=' + with_modules.to_string('1', '0'), + variables: 'modules=' + dl_dep.found().to_string('1', '0'), ) ## libxml2-config.cmake file @@ -797,12 +773,12 @@ config_cmake.set('LIBXML_MAJOR_VERSION', v_maj) config_cmake.set('LIBXML_MINOR_VERSION', v_min) config_cmake.set('LIBXML_MICRO_VERSION', v_mic) config_cmake.set('VERSION', meson.project_version()) -config_cmake.set('WITH_ICONV', want_iconv.to_int().to_string()) -config_cmake.set('WITH_ICU', want_icu.to_int().to_string()) -config_cmake.set('WITH_LZMA', want_lzma.to_int().to_string()) -config_cmake.set('WITH_MODULES', want_modules.to_int().to_string()) -config_cmake.set('WITH_THREADS', want_threads.to_int().to_string()) -config_cmake.set('WITH_ZLIB', want_zlib.to_int().to_string()) +config_cmake.set('WITH_ICONV', iconv_dep.found().to_int().to_string()) +config_cmake.set('WITH_ICU', icu_dep.found().to_int().to_string()) +config_cmake.set('WITH_LZMA', lzma_dep.found().to_int().to_string()) +config_cmake.set('WITH_MODULES', dl_dep.found().to_int().to_string()) +config_cmake.set('WITH_THREADS', threads_dep.found().to_int().to_string()) +config_cmake.set('WITH_ZLIB', zlib_dep.found().to_int().to_string()) config_cmake.set('XML_CFLAGS', xml_cflags) configure_file( input: 'libxml2-config.cmake.in', @@ -834,13 +810,13 @@ summary( 'history': want_history, 'html': want_html, 'http': want_http, - 'iconv': want_iconv, - 'icu': want_icu, + 'iconv': iconv_dep.found(), + 'icu': icu_dep.found(), 'ipv6': want_ipv6, 'iso8859x': want_iso8859x, 'legacy': want_legacy, - 'lzma': want_lzma, - 'modules': want_modules, + 'lzma': lzma_dep.found(), + 'modules': dl_dep.found(), 'output': want_output, 'pattern': want_pattern, 'push': want_push, @@ -851,7 +827,7 @@ summary( 'sax1': want_sax1, 'schemas': want_schemas, 'schematron': want_schematron, - 'threads': want_threads, + 'threads': threads_dep.found(), 'thread-alloc': want_thread_alloc, 'tls': want_tls, 'tree': want_tree, @@ -861,7 +837,7 @@ summary( 'xpath': want_xpath, 'xptr': want_xptr, 'xptr-locs': want_xptr_locs, - 'zlib': want_zlib, + 'zlib': zlib_dep.found(), }, section: 'Configuration Options Summary:', ) diff --git a/meson_options.txt b/meson_options.txt index 7b4ba08dd..4d61f3d31 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -85,14 +85,12 @@ option('http', # TODO meson custom dependency option('iconv', - type: 'boolean', - value: true, + type: 'feature', description: 'iconv support' ) option('icu', - type: 'boolean', - value: false, + type: 'feature', description: 'ICU support' ) @@ -115,14 +113,12 @@ option('legacy', ) option('lzma', - type: 'boolean', - value: false, + type: 'feature', description: 'LZMA support' ) option('modules', - type: 'boolean', - value: true, + type: 'feature', description: 'Dynamic modules support' ) @@ -187,8 +183,7 @@ option('schematron', ) option('threads', - type: 'boolean', - value: true, + type: 'feature', description: 'Multithreading support' ) @@ -247,8 +242,7 @@ option('xptr-locs', ) option('zlib', - type: 'boolean', - value: false, + type: 'feature', description: 'ZLIB support' ) diff --git a/python/meson.build b/python/meson.build index d5a39fd35..633dc9227 100644 --- a/python/meson.build +++ b/python/meson.build @@ -20,11 +20,11 @@ if py.found() == true setup_py = configuration_data() setup_py.set('prefix', get_option('prefix')) setup_py.set('LIBXML_VERSION', meson.project_version()) - setup_py.set('WITH_ICONV', want_iconv.to_int()) - setup_py.set('WITH_ICU', want_icu.to_int()) - setup_py.set('WITH_LZMA', want_lzma.to_int()) - setup_py.set('WITH_ZLIB', want_zlib.to_int()) - setup_py.set('WITH_THREADS', want_threads.to_int()) + setup_py.set('WITH_ICONV', iconv_dep.found().to_int()) + setup_py.set('WITH_ICU', icu_dep.found().to_int()) + setup_py.set('WITH_LZMA', lzma_dep.found().to_int()) + setup_py.set('WITH_ZLIB', zlib_dep.found().to_int()) + setup_py.set('WITH_THREADS', threads_dep.found().to_int()) configure_file( input: 'setup.py.in', output: 'setup.py', From 8318b5a63465f5805cf3e9ebad794f4db40b5aae Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 9 Jun 2024 14:22:53 +0200 Subject: [PATCH 499/504] parser: Fix NULL checks for output arguments --- entities.c | 3 ++- parser.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/entities.c b/entities.c index 1d033cbf6..f7792a813 100644 --- a/entities.c +++ b/entities.c @@ -290,7 +290,8 @@ xmlAddEntity(xmlDocPtr doc, int extSubset, const xmlChar *name, int type, dtd->last = (xmlNodePtr) ret; } - *out = ret; + if (out != NULL) + *out = ret; return(0); } diff --git a/parser.c b/parser.c index 832229c1f..5f1fdcfac 100644 --- a/parser.c +++ b/parser.c @@ -12172,7 +12172,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctxt, const xmlChar *URL, xmlCtxtInitializeLate(ctxt); list = xmlCtxtParseContent(ctxt, input, /* hasTextDecl */ 1, 1); - if (*listOut != NULL) + if (listOut != NULL) *listOut = list; else xmlFreeNodeList(list); From 4467b89143c5d08f0ee6f2e9996faa8b30c68522 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 12 Jun 2024 13:32:32 +0200 Subject: [PATCH 500/504] Add missing argument checks for new API functions --- parserInternals.c | 6 ++++++ pattern.c | 3 +++ uri.c | 11 +++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/parserInternals.c b/parserInternals.c index a2fe5aad6..6a43cc8f8 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -136,6 +136,9 @@ xmlCtxtErrMemory(xmlParserCtxtPtr ctxt) xmlGenericErrorFunc channel = NULL; void *data; + if (ctxt == NULL) + return; + ctxt->errNo = XML_ERR_NO_MEMORY; ctxt->instate = XML_PARSER_EOF; /* TODO: Remove after refactoring */ ctxt->wellFormed = 0; @@ -1141,6 +1144,9 @@ xmlSwitchInputEncodingName(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, */ int xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding) { + if (ctxt == NULL) + return(-1); + return(xmlSwitchInputEncodingName(ctxt, ctxt->input, encoding)); } diff --git a/pattern.c b/pattern.c index 2b6697680..23b52744a 100644 --- a/pattern.c +++ b/pattern.c @@ -2276,6 +2276,9 @@ xmlPatternCompileSafe(const xmlChar *pattern, xmlDict *dict, int flags, int streamable = 1; int error; + if (patternOut == NULL) + return(1); + if (pattern == NULL) { error = 1; goto error; diff --git a/uri.c b/uri.c index 3803e0ded..370b449f3 100644 --- a/uri.c +++ b/uri.c @@ -980,8 +980,9 @@ xmlParseURISafe(const char *str, xmlURIPtr *uriOut) { xmlURIPtr uri; int ret; - if (uriOut != NULL) - *uriOut = NULL; + if (uriOut == NULL) + return(1); + *uriOut = NULL; if (str == NULL) return(1); @@ -995,8 +996,7 @@ xmlParseURISafe(const char *str, xmlURIPtr *uriOut) { return(ret); } - if (uriOut != NULL) - *uriOut = uri; + *uriOut = uri; return(0); } @@ -2016,6 +2016,9 @@ xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) { xmlURIPtr bas = NULL; xmlURIPtr res = NULL; + if (valPtr == NULL) + return(1); + /* * 1) The URI reference is parsed into the potential four components and * fragment identifier, as described in Section 4.3. From d3fafde7dea638a82687ab4c4115e22202263f47 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 12 Jun 2024 13:33:05 +0200 Subject: [PATCH 501/504] test: Update testapi.c --- gentest.py | 10 +- testapi.c | 1613 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 1340 insertions(+), 283 deletions(-) diff --git a/gentest.py b/gentest.py index 64f0a1be0..82e9487b3 100755 --- a/gentest.py +++ b/gentest.py @@ -213,16 +213,14 @@ extra_post_call = { "xmlAddChild": "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", - "xmlAddEntity": - "if (ret_val != NULL) { xmlFreeNode(ret_val) ; ret_val = NULL; }", "xmlAddChildList": "if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; }", "xmlAddSibling": - "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", + "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", "xmlAddNextSibling": - "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", + "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", "xmlAddPrevSibling": - "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", + "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", "xmlDocSetRootElement": "if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }", "xmlReplaceNode": @@ -259,7 +257,7 @@ "xmlCopyNamespaceList": "if (ret_val != NULL) xmlFreeNsList(ret_val);", "xmlNewTextWriter": "if (ret_val != NULL) out = NULL;", "xmlNewTextWriterPushParser": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} if (ret_val != NULL) ctxt = NULL;", - "xmlNewIOInputStream": "if (ret_val != NULL) input = NULL;", + "xmlNewIOInputStream": "if (ret_val != NULL) buf = NULL;", "htmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", "htmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", "xmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", diff --git a/testapi.c b/testapi.c index ecd995098..d85e56093 100644 --- a/testapi.c +++ b/testapi.c @@ -983,6 +983,13 @@ static void des_void_ptr_ptr(int no ATTRIBUTE_UNUSED, void ** val ATTRIBUTE_UNUS } #endif +#define gen_nb_xmlParserInputPtr 1 +static xmlParserInputPtr gen_xmlParserInputPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { + return(NULL); +} +static void des_xmlParserInputPtr(int no ATTRIBUTE_UNUSED, xmlParserInputPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { +} + /************************************************************************ * * * WARNING: end of the manually maintained part of the test code * @@ -1452,7 +1459,7 @@ test_htmlCreateFileParserCtxt(void) { htmlParserCtxtPtr ret_val; const char * filename; /* the filename */ int n_filename; - const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* optional encoding */ int n_encoding; for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) { @@ -1542,17 +1549,17 @@ test_htmlCreatePushParserCtxt(void) { #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED) int mem_base; htmlParserCtxtPtr ret_val; - htmlSAXHandlerPtr sax; /* a SAX handler */ + htmlSAXHandlerPtr sax; /* a SAX handler (optional) */ int n_sax; - void * user_data; /* The user data returned on SAX callbacks */ + void * user_data; /* The user data returned on SAX callbacks (optional) */ int n_user_data; - const char * chunk; /* a pointer to an array of chars */ + const char * chunk; /* a pointer to an array of chars (optional) */ int n_chunk; int size; /* number of chars in the array */ int n_size; - const char * filename; /* an optional file name or URI */ + const char * filename; /* only used for error reporting (optional) */ int n_filename; - xmlCharEncoding enc; /* an optional encoding */ + xmlCharEncoding enc; /* encoding (deprecated, pass XML_CHAR_ENCODING_NONE) */ int n_enc; for (n_sax = 0;n_sax < gen_nb_htmlSAXHandlerPtr;n_sax++) { @@ -1607,6 +1614,47 @@ test_htmlCreatePushParserCtxt(void) { } +static int +test_htmlCtxtParseDocument(void) { + int test_ret = 0; + +#if defined(LIBXML_HTML_ENABLED) + int mem_base; + htmlDocPtr ret_val; + htmlParserCtxtPtr ctxt; /* an HTML parser context */ + int n_ctxt; + xmlParserInputPtr input; /* parser input */ + int n_input; + + for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) { + mem_base = xmlMemBlocks(); + ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); + input = gen_xmlParserInputPtr(n_input, 1); + + ret_val = htmlCtxtParseDocument(ctxt, input); + desret_htmlDocPtr(ret_val); + call_tests++; + des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputPtr(n_input, input, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in htmlCtxtParseDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_input); + printf("\n"); + } + } + } + function_tests++; +#endif + + return(test_ret); +} + + static int test_htmlCtxtReadDoc(void) { int test_ret = 0; @@ -1618,22 +1666,22 @@ test_htmlCtxtReadDoc(void) { int n_ctxt; const xmlChar * str; /* a pointer to a zero terminated string */ int n_str; - const char * URL; /* the base URL to use for the document */ + const char * URL; /* only used for error reporting (optional) */ int n_URL; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; - int options; /* a combination of htmlParserOption(s) */ + int options; /* a combination of htmlParserOptions */ int n_options; for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { - for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_URL = 0;n_URL < gen_nb_const_char_ptr;n_URL++) { for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { for (n_options = 0;n_options < gen_nb_int;n_options++) { mem_base = xmlMemBlocks(); ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); str = gen_const_xmlChar_ptr(n_str, 1); - URL = gen_filepath(n_URL, 2); + URL = gen_const_char_ptr(n_URL, 2); encoding = gen_const_char_ptr(n_encoding, 3); options = gen_int(n_options, 4); @@ -1642,7 +1690,7 @@ test_htmlCtxtReadDoc(void) { call_tests++; des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); des_const_xmlChar_ptr(n_str, str, 1); - des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_URL, URL, 2); des_const_char_ptr(n_encoding, encoding, 3); des_int(n_options, options, 4); xmlResetLastError(); @@ -1679,9 +1727,9 @@ test_htmlCtxtReadFile(void) { int n_ctxt; const char * filename; /* a file or URL */ int n_filename; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; - int options; /* a combination of htmlParserOption(s) */ + int options; /* a combination of htmlParserOptions */ int n_options; for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { @@ -1725,24 +1773,24 @@ test_htmlCtxtReadMemory(void) { int n_buffer; int size; /* the size of the array */ int n_size; - const char * URL; /* the base URL to use for the document */ + const char * URL; /* only used for error reporting (optional) */ int n_URL; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optinal) */ int n_encoding; - int options; /* a combination of htmlParserOption(s) */ + int options; /* a combination of htmlParserOptions */ int n_options; for (n_ctxt = 0;n_ctxt < gen_nb_htmlParserCtxtPtr;n_ctxt++) { for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { for (n_size = 0;n_size < gen_nb_int;n_size++) { - for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_URL = 0;n_URL < gen_nb_const_char_ptr;n_URL++) { for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { for (n_options = 0;n_options < gen_nb_int;n_options++) { mem_base = xmlMemBlocks(); ctxt = gen_htmlParserCtxtPtr(n_ctxt, 0); buffer = gen_const_char_ptr(n_buffer, 1); size = gen_int(n_size, 2); - URL = gen_filepath(n_URL, 3); + URL = gen_const_char_ptr(n_URL, 3); encoding = gen_const_char_ptr(n_encoding, 4); options = gen_int(n_options, 5); if ((buffer != NULL) && @@ -1755,7 +1803,7 @@ test_htmlCtxtReadMemory(void) { des_htmlParserCtxtPtr(n_ctxt, ctxt, 0); des_const_char_ptr(n_buffer, buffer, 1); des_int(n_size, size, 2); - des_filepath(n_URL, URL, 3); + des_const_char_ptr(n_URL, URL, 3); des_const_char_ptr(n_encoding, encoding, 4); des_int(n_options, options, 5); xmlResetLastError(); @@ -2362,9 +2410,9 @@ test_htmlParseChunk(void) { int ret_val; htmlParserCtxtPtr ctxt; /* an HTML parser context */ int n_ctxt; - const char * chunk; /* an char array */ + const char * chunk; /* chunk of memory */ int n_chunk; - int size; /* the size in byte of the chunk */ + int size; /* size of chunk in bytes */ int n_size; int terminate; /* last chunk indicator */ int n_terminate; @@ -2421,7 +2469,7 @@ test_htmlParseDoc(void) { htmlDocPtr ret_val; const xmlChar * cur; /* a pointer to an array of xmlChar */ int n_cur; - const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* the encoding (optional) */ int n_encoding; for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { @@ -2569,7 +2617,7 @@ test_htmlParseFile(void) { htmlDocPtr ret_val; const char * filename; /* the filename */ int n_filename; - const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* encoding (optional) */ int n_encoding; for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { @@ -2599,30 +2647,30 @@ test_htmlReadDoc(void) { #if defined(LIBXML_HTML_ENABLED) int mem_base; htmlDocPtr ret_val; - const xmlChar * cur; /* a pointer to a zero terminated string */ - int n_cur; - const char * URL; /* the base URL to use for the document */ - int n_URL; - const char * encoding; /* the document encoding, or NULL */ + const xmlChar * str; /* a pointer to a zero terminated string */ + int n_str; + const char * url; /* only used for error reporting (optoinal) */ + int n_url; + const char * encoding; /* the document encoding (optional) */ int n_encoding; - int options; /* a combination of htmlParserOption(s) */ + int options; /* a combination of htmlParserOptions */ int n_options; - for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) { - for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_str = 0;n_str < gen_nb_const_xmlChar_ptr;n_str++) { + for (n_url = 0;n_url < gen_nb_const_char_ptr;n_url++) { for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { for (n_options = 0;n_options < gen_nb_int;n_options++) { mem_base = xmlMemBlocks(); - cur = gen_const_xmlChar_ptr(n_cur, 0); - URL = gen_filepath(n_URL, 1); + str = gen_const_xmlChar_ptr(n_str, 0); + url = gen_const_char_ptr(n_url, 1); encoding = gen_const_char_ptr(n_encoding, 2); options = gen_int(n_options, 3); - ret_val = htmlReadDoc(cur, URL, encoding, options); + ret_val = htmlReadDoc(str, url, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; - des_const_xmlChar_ptr(n_cur, cur, 0); - des_filepath(n_URL, URL, 1); + des_const_xmlChar_ptr(n_str, str, 0); + des_const_char_ptr(n_url, url, 1); des_const_char_ptr(n_encoding, encoding, 2); des_int(n_options, options, 3); xmlResetLastError(); @@ -2630,8 +2678,8 @@ test_htmlReadDoc(void) { printf("Leak of %d blocks found in htmlReadDoc", xmlMemBlocks() - mem_base); test_ret++; - printf(" %d", n_cur); - printf(" %d", n_URL); + printf(" %d", n_str); + printf(" %d", n_url); printf(" %d", n_encoding); printf(" %d", n_options); printf("\n"); @@ -2656,9 +2704,9 @@ test_htmlReadFile(void) { htmlDocPtr ret_val; const char * filename; /* a file or URL */ int n_filename; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; - int options; /* a combination of htmlParserOption(s) */ + int options; /* a combination of htmlParserOptions */ int n_options; for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) { @@ -2706,8 +2754,8 @@ test_htmlReadMemory(void) { int n_buffer; int size; /* the size of the array */ int n_size; - const char * URL; /* the base URL to use for the document */ - int n_URL; + const char * url; /* only used for error reporting (optional) */ + int n_url; const char * encoding; /* the document encoding, or NULL */ int n_encoding; int options; /* a combination of htmlParserOption(s) */ @@ -2715,25 +2763,25 @@ test_htmlReadMemory(void) { for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { for (n_size = 0;n_size < gen_nb_int;n_size++) { - for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_url = 0;n_url < gen_nb_const_char_ptr;n_url++) { for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { for (n_options = 0;n_options < gen_nb_int;n_options++) { mem_base = xmlMemBlocks(); buffer = gen_const_char_ptr(n_buffer, 0); size = gen_int(n_size, 1); - URL = gen_filepath(n_URL, 2); + url = gen_const_char_ptr(n_url, 2); encoding = gen_const_char_ptr(n_encoding, 3); options = gen_int(n_options, 4); if ((buffer != NULL) && (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = htmlReadMemory(buffer, size, URL, encoding, options); + ret_val = htmlReadMemory(buffer, size, url, encoding, options); desret_htmlDocPtr(ret_val); call_tests++; des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); - des_filepath(n_URL, URL, 2); + des_const_char_ptr(n_url, url, 2); des_const_char_ptr(n_encoding, encoding, 3); des_int(n_options, options, 4); xmlResetLastError(); @@ -2743,7 +2791,7 @@ test_htmlReadMemory(void) { test_ret++; printf(" %d", n_buffer); printf(" %d", n_size); - printf(" %d", n_URL); + printf(" %d", n_url); printf(" %d", n_encoding); printf(" %d", n_options); printf("\n"); @@ -2824,7 +2872,7 @@ test_htmlSAXParseFile(void) { htmlDocPtr ret_val; const char * filename; /* the filename */ int n_filename; - const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */ + const char * encoding; /* encoding (optional) */ int n_encoding; htmlSAXHandlerPtr sax; /* the SAX handler block */ int n_sax; @@ -2883,13 +2931,14 @@ static int test_HTMLparser(void) { int test_ret = 0; - if (quiet == 0) printf("Testing HTMLparser : 35 of 41 functions ...\n"); + if (quiet == 0) printf("Testing HTMLparser : 36 of 42 functions ...\n"); test_ret += test_UTF8ToHtml(); test_ret += test_htmlAttrAllowed(); test_ret += test_htmlAutoCloseTag(); test_ret += test_htmlCreateFileParserCtxt(); test_ret += test_htmlCreateMemoryParserCtxt(); test_ret += test_htmlCreatePushParserCtxt(); + test_ret += test_htmlCtxtParseDocument(); test_ret += test_htmlCtxtReadDoc(); test_ret += test_htmlCtxtReadFile(); test_ret += test_htmlCtxtReadMemory(); @@ -9081,6 +9130,16 @@ test_xmlInitCharEncodingHandlers(void) { } +static int +test_xmlLookupCharEncodingHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlNewCharEncodingHandler(void) { int test_ret = 0; @@ -9091,6 +9150,16 @@ test_xmlNewCharEncodingHandler(void) { } +static int +test_xmlOpenCharEncodingHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlParseCharEncoding(void) { int test_ret = 0; @@ -9160,7 +9229,7 @@ static int test_encoding(void) { int test_ret = 0; - if (quiet == 0) printf("Testing encoding : 16 of 19 functions ...\n"); + if (quiet == 0) printf("Testing encoding : 16 of 21 functions ...\n"); test_ret += test_UTF8Toisolat1(); test_ret += test_isolat1ToUTF8(); test_ret += test_xmlAddEncodingAlias(); @@ -9177,7 +9246,9 @@ test_encoding(void) { test_ret += test_xmlGetCharEncodingName(); test_ret += test_xmlGetEncodingAlias(); test_ret += test_xmlInitCharEncodingHandlers(); + test_ret += test_xmlLookupCharEncodingHandler(); test_ret += test_xmlNewCharEncodingHandler(); + test_ret += test_xmlOpenCharEncodingHandler(); test_ret += test_xmlParseCharEncoding(); test_ret += test_xmlRegisterCharEncodingHandler(); @@ -9320,6 +9391,91 @@ test_xmlAddDtdEntity(void) { } +#define gen_nb_xmlEntityPtr_ptr 1 +#define gen_xmlEntityPtr_ptr(no, nr) NULL +#define des_xmlEntityPtr_ptr(no, val, nr) + +static int +test_xmlAddEntity(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlDocPtr doc; /* the document */ + int n_doc; + int extSubset; /* add to the external or internal subset */ + int n_extSubset; + const xmlChar * name; /* the entity name */ + int n_name; + int type; /* the entity type XML_xxx_yyy_ENTITY */ + int n_type; + const xmlChar * ExternalID; /* the entity external ID if available */ + int n_ExternalID; + const xmlChar * SystemID; /* the entity system ID if available */ + int n_SystemID; + const xmlChar * content; /* the entity content */ + int n_content; + xmlEntityPtr * out; /* pointer to resulting entity (optional) */ + int n_out; + + for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { + for (n_extSubset = 0;n_extSubset < gen_nb_int;n_extSubset++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_type = 0;n_type < gen_nb_int;n_type++) { + for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) { + for (n_SystemID = 0;n_SystemID < gen_nb_const_xmlChar_ptr;n_SystemID++) { + for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { + for (n_out = 0;n_out < gen_nb_xmlEntityPtr_ptr;n_out++) { + mem_base = xmlMemBlocks(); + doc = gen_xmlDocPtr(n_doc, 0); + extSubset = gen_int(n_extSubset, 1); + name = gen_const_xmlChar_ptr(n_name, 2); + type = gen_int(n_type, 3); + ExternalID = gen_const_xmlChar_ptr(n_ExternalID, 4); + SystemID = gen_const_xmlChar_ptr(n_SystemID, 5); + content = gen_const_xmlChar_ptr(n_content, 6); + out = gen_xmlEntityPtr_ptr(n_out, 7); + + ret_val = xmlAddEntity(doc, extSubset, name, type, ExternalID, SystemID, content, out); + desret_int(ret_val); + call_tests++; + des_xmlDocPtr(n_doc, doc, 0); + des_int(n_extSubset, extSubset, 1); + des_const_xmlChar_ptr(n_name, name, 2); + des_int(n_type, type, 3); + des_const_xmlChar_ptr(n_ExternalID, ExternalID, 4); + des_const_xmlChar_ptr(n_SystemID, SystemID, 5); + des_const_xmlChar_ptr(n_content, content, 6); + des_xmlEntityPtr_ptr(n_out, out, 7); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddEntity", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_extSubset); + printf(" %d", n_name); + printf(" %d", n_type); + printf(" %d", n_ExternalID); + printf(" %d", n_SystemID); + printf(" %d", n_content); + printf(" %d", n_out); + printf("\n"); + } + } + } + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCopyEntitiesTable(void) { int test_ret = 0; @@ -9727,9 +9883,10 @@ static int test_entities(void) { int test_ret = 0; - if (quiet == 0) printf("Testing entities : 11 of 18 functions ...\n"); + if (quiet == 0) printf("Testing entities : 12 of 19 functions ...\n"); test_ret += test_xmlAddDocEntity(); test_ret += test_xmlAddDtdEntity(); + test_ret += test_xmlAddEntity(); test_ret += test_xmlCopyEntitiesTable(); test_ret += test_xmlCreateEntitiesTable(); test_ret += test_xmlDumpEntitiesTable(); @@ -9747,6 +9904,165 @@ test_entities(void) { return(test_ret); } +static int +test_xmlHashAdd(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr hash; /* hash table */ + int n_hash; + const xmlChar * key; /* string key */ + int n_key; + void * payload; /* pointer to the payload */ + int n_payload; + + for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { + for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) { + for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) { + mem_base = xmlMemBlocks(); + hash = gen_xmlHashTablePtr(n_hash, 0); + key = gen_const_xmlChar_ptr(n_key, 1); + payload = gen_void_ptr(n_payload, 2); + + ret_val = xmlHashAdd(hash, key, payload); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_hash, hash, 0); + des_const_xmlChar_ptr(n_key, key, 1); + des_void_ptr(n_payload, payload, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashAdd", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_hash); + printf(" %d", n_key); + printf(" %d", n_payload); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashAdd2(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr hash; /* hash table */ + int n_hash; + const xmlChar * key; /* first string key */ + int n_key; + const xmlChar * key2; /* second string key */ + int n_key2; + void * payload; /* pointer to the payload */ + int n_payload; + + for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { + for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) { + for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) { + for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) { + mem_base = xmlMemBlocks(); + hash = gen_xmlHashTablePtr(n_hash, 0); + key = gen_const_xmlChar_ptr(n_key, 1); + key2 = gen_const_xmlChar_ptr(n_key2, 2); + payload = gen_void_ptr(n_payload, 3); + + ret_val = xmlHashAdd2(hash, key, key2, payload); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_hash, hash, 0); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); + des_void_ptr(n_payload, payload, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashAdd2", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_hash); + printf(" %d", n_key); + printf(" %d", n_key2); + printf(" %d", n_payload); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlHashAdd3(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlHashTablePtr hash; /* hash table */ + int n_hash; + const xmlChar * key; /* first string key */ + int n_key; + const xmlChar * key2; /* second string key */ + int n_key2; + const xmlChar * key3; /* third string key */ + int n_key3; + void * payload; /* pointer to the payload */ + int n_payload; + + for (n_hash = 0;n_hash < gen_nb_xmlHashTablePtr;n_hash++) { + for (n_key = 0;n_key < gen_nb_const_xmlChar_ptr;n_key++) { + for (n_key2 = 0;n_key2 < gen_nb_const_xmlChar_ptr;n_key2++) { + for (n_key3 = 0;n_key3 < gen_nb_const_xmlChar_ptr;n_key3++) { + for (n_payload = 0;n_payload < gen_nb_void_ptr;n_payload++) { + mem_base = xmlMemBlocks(); + hash = gen_xmlHashTablePtr(n_hash, 0); + key = gen_const_xmlChar_ptr(n_key, 1); + key2 = gen_const_xmlChar_ptr(n_key2, 2); + key3 = gen_const_xmlChar_ptr(n_key3, 3); + payload = gen_void_ptr(n_payload, 4); + + ret_val = xmlHashAdd3(hash, key, key2, key3, payload); + desret_int(ret_val); + call_tests++; + des_xmlHashTablePtr(n_hash, hash, 0); + des_const_xmlChar_ptr(n_key, key, 1); + des_const_xmlChar_ptr(n_key2, key2, 2); + des_const_xmlChar_ptr(n_key3, key3, 3); + des_void_ptr(n_payload, payload, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlHashAdd3", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_hash); + printf(" %d", n_key); + printf(" %d", n_key2); + printf(" %d", n_key3); + printf(" %d", n_payload); + printf("\n"); + } + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlHashAddEntry(void) { int test_ret = 0; @@ -9916,6 +10232,16 @@ test_xmlHashCopy(void) { } +static int +test_xmlHashCopySafe(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlHashCreate(void) { int test_ret = 0; @@ -10705,11 +11031,15 @@ static int test_hash(void) { int test_ret = 0; - if (quiet == 0) printf("Testing hash : 17 of 25 functions ...\n"); + if (quiet == 0) printf("Testing hash : 20 of 29 functions ...\n"); + test_ret += test_xmlHashAdd(); + test_ret += test_xmlHashAdd2(); + test_ret += test_xmlHashAdd3(); test_ret += test_xmlHashAddEntry(); test_ret += test_xmlHashAddEntry2(); test_ret += test_xmlHashAddEntry3(); test_ret += test_xmlHashCopy(); + test_ret += test_xmlHashCopySafe(); test_ret += test_xmlHashCreate(); test_ret += test_xmlHashCreateDict(); test_ret += test_xmlHashDefaultDeallocator(); @@ -12047,6 +12377,29 @@ test_xmlByteConsumed(void) { } +static int +test_xmlCleanupGlobals(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlCleanupGlobals(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCleanupGlobals", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + static int test_xmlClearNodeInfoSeq(void) { int test_ret = 0; @@ -12146,15 +12499,15 @@ test_xmlCreatePushParserCtxt(void) { #if defined(LIBXML_PUSH_ENABLED) int mem_base; xmlParserCtxtPtr ret_val; - xmlSAXHandlerPtr sax; /* a SAX handler */ + xmlSAXHandlerPtr sax; /* a SAX handler (optional) */ int n_sax; - void * user_data; /* The user data returned on SAX callbacks */ + void * user_data; /* user data for SAX callbacks (optional) */ int n_user_data; - const char * chunk; /* a pointer to an array of chars */ + const char * chunk; /* initial chunk (optional, deprecated) */ int n_chunk; - int size; /* number of chars in the array */ + int size; /* size of initial chunk in bytes */ int n_size; - const char * filename; /* an optional file name or URI */ + const char * filename; /* file name or URI (optional) */ int n_filename; for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { @@ -12204,6 +12557,45 @@ test_xmlCreatePushParserCtxt(void) { } +static int +test_xmlCtxtParseDocument(void) { + int test_ret = 0; + + int mem_base; + xmlDocPtr ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + xmlParserInputPtr input; /* parser input */ + int n_input; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + input = gen_xmlParserInputPtr(n_input, 1); + + ret_val = xmlCtxtParseDocument(ctxt, input); + desret_xmlDocPtr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlParserInputPtr(n_input, input, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtParseDocument", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_input); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCtxtReadDoc(void) { int test_ret = 0; @@ -12214,9 +12606,9 @@ test_xmlCtxtReadDoc(void) { int n_ctxt; const xmlChar * str; /* a pointer to a zero terminated string */ int n_str; - const char * URL; /* the base URL to use for the document */ + const char * URL; /* base URL (optional) */ int n_URL; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -12274,7 +12666,7 @@ test_xmlCtxtReadFile(void) { int n_ctxt; const char * filename; /* a file or URL */ int n_filename; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -12329,9 +12721,9 @@ test_xmlCtxtReadMemory(void) { int n_buffer; int size; /* the size of the array */ int n_size; - const char * URL; /* the base URL to use for the document */ + const char * URL; /* base URL (optional) */ int n_URL; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -12480,6 +12872,16 @@ test_xmlCtxtResetPush(void) { } +static int +test_xmlCtxtSetErrorHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlCtxtSetMaxAmplification(void) { int test_ret = 0; @@ -12490,6 +12892,45 @@ test_xmlCtxtSetMaxAmplification(void) { } +static int +test_xmlCtxtSetOptions(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + int options; /* a bitmask of xmlParserOption values */ + int n_options; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + options = gen_parseroptions(n_options, 1); + + ret_val = xmlCtxtSetOptions(ctxt, options); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_parseroptions(n_options, options, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtSetOptions", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_options); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCtxtUseOptions(void) { int test_ret = 0; @@ -12611,6 +13052,29 @@ test_xmlIOParseDTD(void) { } +static int +test_xmlInitGlobals(void) { + int test_ret = 0; + + int mem_base; + + mem_base = xmlMemBlocks(); + + xmlInitGlobals(); + call_tests++; + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlInitGlobals", + xmlMemBlocks() - mem_base); + test_ret++; + printf("\n"); + } + function_tests++; + + return(test_ret); +} + + static int test_xmlInitNodeInfoSeq(void) { int test_ret = 0; @@ -12814,25 +13278,25 @@ test_xmlNewIOInputStream(void) { xmlParserInputPtr ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - xmlParserInputBufferPtr input; /* an I/O Input */ - int n_input; + xmlParserInputBufferPtr buf; /* an input buffer */ + int n_buf; xmlCharEncoding enc; /* the charset encoding if known */ int n_enc; for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { - for (n_input = 0;n_input < gen_nb_xmlParserInputBufferPtr;n_input++) { + for (n_buf = 0;n_buf < gen_nb_xmlParserInputBufferPtr;n_buf++) { for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { mem_base = xmlMemBlocks(); ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); - input = gen_xmlParserInputBufferPtr(n_input, 1); + buf = gen_xmlParserInputBufferPtr(n_buf, 1); enc = gen_xmlCharEncoding(n_enc, 2); - ret_val = xmlNewIOInputStream(ctxt, input, enc); - if (ret_val != NULL) input = NULL; + ret_val = xmlNewIOInputStream(ctxt, buf, enc); + if (ret_val != NULL) buf = NULL; desret_xmlParserInputPtr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_xmlParserInputBufferPtr(n_input, input, 1); + des_xmlParserInputBufferPtr(n_buf, buf, 1); des_xmlCharEncoding(n_enc, enc, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -12840,7 +13304,7 @@ test_xmlNewIOInputStream(void) { xmlMemBlocks() - mem_base); test_ret++; printf(" %d", n_ctxt); - printf(" %d", n_input); + printf(" %d", n_buf); printf(" %d", n_enc); printf("\n"); } @@ -13019,8 +13483,8 @@ test_xmlParseBalancedChunkMemoryRecover(void) { int n_depth; const xmlChar * string; /* the input string in UTF8 or ISO-Latin (zero terminated) */ int n_string; - xmlNodePtr * lst; /* the return value for the set of parsed nodes */ - int n_lst; + xmlNodePtr * listOut; /* the return value for the set of parsed nodes */ + int n_listOut; int recover; /* return nodes even if the data is broken (use 0) */ int n_recover; @@ -13029,7 +13493,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) { for (n_user_data = 0;n_user_data < gen_nb_userdata;n_user_data++) { for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { for (n_string = 0;n_string < gen_nb_const_xmlChar_ptr;n_string++) { - for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + for (n_listOut = 0;n_listOut < gen_nb_xmlNodePtr_ptr;n_listOut++) { for (n_recover = 0;n_recover < gen_nb_int;n_recover++) { mem_base = xmlMemBlocks(); doc = gen_xmlDocPtr(n_doc, 0); @@ -13037,7 +13501,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) { user_data = gen_userdata(n_user_data, 2); depth = gen_int(n_depth, 3); string = gen_const_xmlChar_ptr(n_string, 4); - lst = gen_xmlNodePtr_ptr(n_lst, 5); + listOut = gen_xmlNodePtr_ptr(n_listOut, 5); recover = gen_int(n_recover, 6); #ifdef LIBXML_SAX1_ENABLED @@ -13045,7 +13509,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) { #endif - ret_val = xmlParseBalancedChunkMemoryRecover(doc, sax, user_data, depth, string, lst, recover); + ret_val = xmlParseBalancedChunkMemoryRecover(doc, sax, user_data, depth, string, listOut, recover); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); @@ -13053,7 +13517,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) { des_userdata(n_user_data, user_data, 2); des_int(n_depth, depth, 3); des_const_xmlChar_ptr(n_string, string, 4); - des_xmlNodePtr_ptr(n_lst, lst, 5); + des_xmlNodePtr_ptr(n_listOut, listOut, 5); des_int(n_recover, recover, 6); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { @@ -13065,7 +13529,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) { printf(" %d", n_user_data); printf(" %d", n_depth); printf(" %d", n_string); - printf(" %d", n_lst); + printf(" %d", n_listOut); printf(" %d", n_recover); printf("\n"); } @@ -13093,9 +13557,9 @@ test_xmlParseChunk(void) { int ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - const char * chunk; /* an char array */ + const char * chunk; /* chunk of memory */ int n_chunk; - int size; /* the size in byte of the chunk */ + int size; /* size of chunk in bytes */ int n_size; int terminate; /* last chunk indicator */ int n_terminate; @@ -13149,41 +13613,41 @@ test_xmlParseCtxtExternalEntity(void) { int mem_base; int ret_val; - xmlParserCtxtPtr ctx; /* the existing parsing context */ - int n_ctx; + xmlParserCtxtPtr ctxt; /* the existing parsing context */ + int n_ctxt; const xmlChar * URL; /* the URL for the entity to load */ int n_URL; const xmlChar * ID; /* the System ID for the entity to load */ int n_ID; - xmlNodePtr * lst; /* the return value for the set of parsed nodes */ - int n_lst; + xmlNodePtr * listOut; /* the return value for the set of parsed nodes */ + int n_listOut; - for (n_ctx = 0;n_ctx < gen_nb_xmlParserCtxtPtr;n_ctx++) { + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { for (n_URL = 0;n_URL < gen_nb_const_xmlChar_ptr;n_URL++) { for (n_ID = 0;n_ID < gen_nb_const_xmlChar_ptr;n_ID++) { - for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + for (n_listOut = 0;n_listOut < gen_nb_xmlNodePtr_ptr;n_listOut++) { mem_base = xmlMemBlocks(); - ctx = gen_xmlParserCtxtPtr(n_ctx, 0); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); URL = gen_const_xmlChar_ptr(n_URL, 1); ID = gen_const_xmlChar_ptr(n_ID, 2); - lst = gen_xmlNodePtr_ptr(n_lst, 3); + listOut = gen_xmlNodePtr_ptr(n_listOut, 3); - ret_val = xmlParseCtxtExternalEntity(ctx, URL, ID, lst); + ret_val = xmlParseCtxtExternalEntity(ctxt, URL, ID, listOut); desret_int(ret_val); call_tests++; - des_xmlParserCtxtPtr(n_ctx, ctx, 0); + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); des_const_xmlChar_ptr(n_URL, URL, 1); des_const_xmlChar_ptr(n_ID, ID, 2); - des_xmlNodePtr_ptr(n_lst, lst, 3); + des_xmlNodePtr_ptr(n_listOut, listOut, 3); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParseCtxtExternalEntity", xmlMemBlocks() - mem_base); test_ret++; - printf(" %d", n_ctx); + printf(" %d", n_ctxt); printf(" %d", n_URL); printf(" %d", n_ID); - printf(" %d", n_lst); + printf(" %d", n_listOut); printf("\n"); } } @@ -13397,8 +13861,8 @@ test_xmlParseExternalEntity(void) { int n_URL; const xmlChar * ID; /* the System ID for the entity to load */ int n_ID; - xmlNodePtr * lst; /* the return value for the set of parsed nodes */ - int n_lst; + xmlNodePtr * list; /* the return value for the set of parsed nodes */ + int n_list; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { for (n_sax = 0;n_sax < gen_nb_xmlSAXHandlerPtr;n_sax++) { @@ -13406,7 +13870,7 @@ test_xmlParseExternalEntity(void) { for (n_depth = 0;n_depth < gen_nb_int;n_depth++) { for (n_URL = 0;n_URL < gen_nb_const_xmlChar_ptr;n_URL++) { for (n_ID = 0;n_ID < gen_nb_const_xmlChar_ptr;n_ID++) { - for (n_lst = 0;n_lst < gen_nb_xmlNodePtr_ptr;n_lst++) { + for (n_list = 0;n_list < gen_nb_xmlNodePtr_ptr;n_list++) { mem_base = xmlMemBlocks(); doc = gen_xmlDocPtr(n_doc, 0); sax = gen_xmlSAXHandlerPtr(n_sax, 1); @@ -13414,9 +13878,9 @@ test_xmlParseExternalEntity(void) { depth = gen_int(n_depth, 3); URL = gen_const_xmlChar_ptr(n_URL, 4); ID = gen_const_xmlChar_ptr(n_ID, 5); - lst = gen_xmlNodePtr_ptr(n_lst, 6); + list = gen_xmlNodePtr_ptr(n_list, 6); - ret_val = xmlParseExternalEntity(doc, sax, user_data, depth, URL, ID, lst); + ret_val = xmlParseExternalEntity(doc, sax, user_data, depth, URL, ID, list); desret_int(ret_val); call_tests++; des_xmlDocPtr(n_doc, doc, 0); @@ -13425,7 +13889,7 @@ test_xmlParseExternalEntity(void) { des_int(n_depth, depth, 3); des_const_xmlChar_ptr(n_URL, URL, 4); des_const_xmlChar_ptr(n_ID, ID, 5); - des_xmlNodePtr_ptr(n_lst, lst, 6); + des_xmlNodePtr_ptr(n_list, list, 6); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlParseExternalEntity", @@ -13437,7 +13901,7 @@ test_xmlParseExternalEntity(void) { printf(" %d", n_depth); printf(" %d", n_URL); printf(" %d", n_ID); - printf(" %d", n_lst); + printf(" %d", n_list); printf("\n"); } } @@ -13716,10 +14180,6 @@ test_xmlParserFindNodeInfoIndex(void) { } -#define gen_nb_xmlParserInputPtr 1 -#define gen_xmlParserInputPtr(no, nr) NULL -#define des_xmlParserInputPtr(no, val, nr) - static int test_xmlParserInputGrow(void) { int test_ret = 0; @@ -13838,9 +14298,9 @@ test_xmlReadDoc(void) { xmlDocPtr ret_val; const xmlChar * cur; /* a pointer to a zero terminated string */ int n_cur; - const char * URL; /* the base URL to use for the document */ + const char * URL; /* base URL (optional) */ int n_URL; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -13891,7 +14351,7 @@ test_xmlReadFile(void) { xmlDocPtr ret_val; const char * filename; /* a file or URL */ int n_filename; - const char * encoding; /* the document encoding, or NULL */ + const char * encoding; /* the document encoding (optional) */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; @@ -13939,34 +14399,34 @@ test_xmlReadMemory(void) { int n_buffer; int size; /* the size of the array */ int n_size; - const char * URL; /* the base URL to use for the document */ - int n_URL; - const char * encoding; /* the document encoding, or NULL */ + const char * url; /* base URL (optional) */ + int n_url; + const char * encoding; /* the document encoding (optional) */ int n_encoding; int options; /* a combination of xmlParserOption */ int n_options; for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) { for (n_size = 0;n_size < gen_nb_int;n_size++) { - for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) { + for (n_url = 0;n_url < gen_nb_filepath;n_url++) { for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) { mem_base = xmlMemBlocks(); buffer = gen_const_char_ptr(n_buffer, 0); size = gen_int(n_size, 1); - URL = gen_filepath(n_URL, 2); + url = gen_filepath(n_url, 2); encoding = gen_const_char_ptr(n_encoding, 3); options = gen_parseroptions(n_options, 4); if ((buffer != NULL) && (size > xmlStrlen(BAD_CAST buffer))) size = 0; - ret_val = xmlReadMemory(buffer, size, URL, encoding, options); + ret_val = xmlReadMemory(buffer, size, url, encoding, options); desret_xmlDocPtr(ret_val); call_tests++; des_const_char_ptr(n_buffer, buffer, 0); des_int(n_size, size, 1); - des_filepath(n_URL, URL, 2); + des_filepath(n_url, url, 2); des_const_char_ptr(n_encoding, encoding, 3); des_parseroptions(n_options, options, 4); xmlResetLastError(); @@ -13976,7 +14436,7 @@ test_xmlReadMemory(void) { test_ret++; printf(" %d", n_buffer); printf(" %d", n_size); - printf(" %d", n_URL); + printf(" %d", n_url); printf(" %d", n_encoding); printf(" %d", n_options); printf("\n"); @@ -14988,22 +15448,27 @@ static int test_parser(void) { int test_ret = 0; - if (quiet == 0) printf("Testing parser : 67 of 80 functions ...\n"); + if (quiet == 0) printf("Testing parser : 71 of 85 functions ...\n"); test_ret += test_xmlByteConsumed(); + test_ret += test_xmlCleanupGlobals(); test_ret += test_xmlClearNodeInfoSeq(); test_ret += test_xmlClearParserCtxt(); test_ret += test_xmlCreateDocParserCtxt(); test_ret += test_xmlCreatePushParserCtxt(); + test_ret += test_xmlCtxtParseDocument(); test_ret += test_xmlCtxtReadDoc(); test_ret += test_xmlCtxtReadFile(); test_ret += test_xmlCtxtReadMemory(); test_ret += test_xmlCtxtReset(); test_ret += test_xmlCtxtResetPush(); + test_ret += test_xmlCtxtSetErrorHandler(); test_ret += test_xmlCtxtSetMaxAmplification(); + test_ret += test_xmlCtxtSetOptions(); test_ret += test_xmlCtxtUseOptions(); test_ret += test_xmlGetExternalEntityLoader(); test_ret += test_xmlHasFeature(); test_ret += test_xmlIOParseDTD(); + test_ret += test_xmlInitGlobals(); test_ret += test_xmlInitNodeInfoSeq(); test_ret += test_xmlInitParser(); test_ret += test_xmlInitParserCtxt(); @@ -15554,6 +16019,36 @@ test_xmlCreateURLParserCtxt(void) { } +static int +test_xmlCtxtErrMemory(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + xmlCtxtErrMemory(ctxt); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtErrMemory", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCurrentChar(void) { int test_ret = 0; @@ -15633,27 +16128,27 @@ test_xmlNewEntityInputStream(void) { xmlParserInputPtr ret_val; xmlParserCtxtPtr ctxt; /* an XML parser context */ int n_ctxt; - xmlEntityPtr entity; /* an Entity pointer */ - int n_entity; + xmlEntityPtr ent; /* an Entity pointer */ + int n_ent; for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { - for (n_entity = 0;n_entity < gen_nb_xmlEntityPtr;n_entity++) { + for (n_ent = 0;n_ent < gen_nb_xmlEntityPtr;n_ent++) { mem_base = xmlMemBlocks(); ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); - entity = gen_xmlEntityPtr(n_entity, 1); + ent = gen_xmlEntityPtr(n_ent, 1); - ret_val = xmlNewEntityInputStream(ctxt, entity); + ret_val = xmlNewEntityInputStream(ctxt, ent); desret_xmlParserInputPtr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); - des_xmlEntityPtr(n_entity, entity, 1); + des_xmlEntityPtr(n_ent, ent, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlNewEntityInputStream", xmlMemBlocks() - mem_base); test_ret++; printf(" %d", n_ctxt); - printf(" %d", n_entity); + printf(" %d", n_ent); printf("\n"); } } @@ -15925,23 +16420,23 @@ test_xmlSplitQName(void) { int n_ctxt; const xmlChar * name; /* an XML parser context */ int n_name; - xmlChar ** prefix; /* a xmlChar ** */ - int n_prefix; + xmlChar ** prefixOut; /* a xmlChar ** */ + int n_prefixOut; for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { - for (n_prefix = 0;n_prefix < gen_nb_xmlChar_ptr_ptr;n_prefix++) { + for (n_prefixOut = 0;n_prefixOut < gen_nb_xmlChar_ptr_ptr;n_prefixOut++) { mem_base = xmlMemBlocks(); ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); name = gen_const_xmlChar_ptr(n_name, 1); - prefix = gen_xmlChar_ptr_ptr(n_prefix, 2); + prefixOut = gen_xmlChar_ptr_ptr(n_prefixOut, 2); - ret_val = xmlSplitQName(ctxt, name, prefix); + ret_val = xmlSplitQName(ctxt, name, prefixOut); desret_xmlChar_ptr(ret_val); call_tests++; des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); des_const_xmlChar_ptr(n_name, name, 1); - des_xmlChar_ptr_ptr(n_prefix, prefix, 2); + des_xmlChar_ptr_ptr(n_prefixOut, prefixOut, 2); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlSplitQName", @@ -15949,7 +16444,7 @@ test_xmlSplitQName(void) { test_ret++; printf(" %d", n_ctxt); printf(" %d", n_name); - printf(" %d", n_prefix); + printf(" %d", n_prefixOut); printf("\n"); } } @@ -16191,13 +16686,52 @@ test_xmlSwitchEncoding(void) { static int -test_xmlSwitchInputEncoding(void) { +test_xmlSwitchEncodingName(void) { int test_ret = 0; int mem_base; int ret_val; xmlParserCtxtPtr ctxt; /* the parser context */ int n_ctxt; + const char * encoding; /* the encoding name */ + int n_encoding; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + encoding = gen_const_char_ptr(n_encoding, 1); + + ret_val = xmlSwitchEncodingName(ctxt, encoding); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_const_char_ptr(n_encoding, encoding, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSwitchEncodingName", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_encoding); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlSwitchInputEncoding(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* the parser context, only for error reporting */ + int n_ctxt; xmlParserInputPtr input; /* the input stream */ int n_input; xmlCharEncodingHandlerPtr handler; /* the encoding handler */ @@ -16278,7 +16812,7 @@ static int test_parserInternals(void) { int test_ret = 0; - if (quiet == 0) printf("Testing parserInternals : 30 of 87 functions ...\n"); + if (quiet == 0) printf("Testing parserInternals : 32 of 89 functions ...\n"); test_ret += test_inputPop(); test_ret += test_inputPush(); test_ret += test_namePop(); @@ -16292,6 +16826,7 @@ test_parserInternals(void) { test_ret += test_xmlCreateFileParserCtxt(); test_ret += test_xmlCreateMemoryParserCtxt(); test_ret += test_xmlCreateURLParserCtxt(); + test_ret += test_xmlCtxtErrMemory(); test_ret += test_xmlCurrentChar(); test_ret += test_xmlIsLetter(); test_ret += test_xmlNewEntityInputStream(); @@ -16308,6 +16843,7 @@ test_parserInternals(void) { test_ret += test_xmlStringDecodeEntities(); test_ret += test_xmlStringLenDecodeEntities(); test_ret += test_xmlSwitchEncoding(); + test_ret += test_xmlSwitchEncodingName(); test_ret += test_xmlSwitchInputEncoding(); test_ret += test_xmlSwitchToEncoding(); @@ -16315,6 +16851,75 @@ test_parserInternals(void) { printf("Module parserInternals: %d errors\n", test_ret); return(test_ret); } +#ifdef LIBXML_PATTERN_ENABLED + +#define gen_nb_xmlPatternPtr_ptr 1 +#define gen_xmlPatternPtr_ptr(no, nr) NULL +#define des_xmlPatternPtr_ptr(no, val, nr) +#endif + + +static int +test_xmlPatternCompileSafe(void) { + int test_ret = 0; + +#if defined(LIBXML_PATTERN_ENABLED) + int mem_base; + int ret_val; + const xmlChar * pattern; /* the pattern to compile */ + int n_pattern; + xmlDict * dict; /* an optional dictionary for interned strings */ + int n_dict; + int flags; /* compilation flags, see xmlPatternFlags */ + int n_flags; + const xmlChar ** namespaces; /* the prefix definitions, array of [URI, prefix] or NULL */ + int n_namespaces; + xmlPatternPtr * patternOut; /* output pattern */ + int n_patternOut; + + for (n_pattern = 0;n_pattern < gen_nb_const_xmlChar_ptr;n_pattern++) { + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + for (n_flags = 0;n_flags < gen_nb_int;n_flags++) { + for (n_namespaces = 0;n_namespaces < gen_nb_const_xmlChar_ptr_ptr;n_namespaces++) { + for (n_patternOut = 0;n_patternOut < gen_nb_xmlPatternPtr_ptr;n_patternOut++) { + mem_base = xmlMemBlocks(); + pattern = gen_const_xmlChar_ptr(n_pattern, 0); + dict = gen_xmlDictPtr(n_dict, 1); + flags = gen_int(n_flags, 2); + namespaces = gen_const_xmlChar_ptr_ptr(n_namespaces, 3); + patternOut = gen_xmlPatternPtr_ptr(n_patternOut, 4); + + ret_val = xmlPatternCompileSafe(pattern, dict, flags, namespaces, patternOut); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_pattern, pattern, 0); + des_xmlDictPtr(n_dict, dict, 1); + des_int(n_flags, flags, 2); + des_const_xmlChar_ptr_ptr(n_namespaces, namespaces, 3); + des_xmlPatternPtr_ptr(n_patternOut, patternOut, 4); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlPatternCompileSafe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_pattern); + printf(" %d", n_dict); + printf(" %d", n_flags); + printf(" %d", n_namespaces); + printf(" %d", n_patternOut); + printf("\n"); + } + } + } + } + } + } + function_tests++; +#endif + + return(test_ret); +} + static int test_xmlPatternFromRoot(void) { @@ -16742,7 +17347,8 @@ static int test_pattern(void) { int test_ret = 0; - if (quiet == 0) printf("Testing pattern : 10 of 15 functions ...\n"); + if (quiet == 0) printf("Testing pattern : 11 of 16 functions ...\n"); + test_ret += test_xmlPatternCompileSafe(); test_ret += test_xmlPatternFromRoot(); test_ret += test_xmlPatternGetStreamCtxt(); test_ret += test_xmlPatternMatch(); @@ -17711,30 +18317,30 @@ test_xmlAddNextSibling(void) { int mem_base; xmlNodePtr ret_val; - xmlNodePtr cur; /* the child node */ + xmlNodePtr prev; /* the target node */ + int n_prev; + xmlNodePtr cur; /* the new node */ int n_cur; - xmlNodePtr elem; /* the new node */ - int n_elem; - for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { - for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) { + for (n_prev = 0;n_prev < gen_nb_xmlNodePtr;n_prev++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) { mem_base = xmlMemBlocks(); - cur = gen_xmlNodePtr(n_cur, 0); - elem = gen_xmlNodePtr_in(n_elem, 1); + prev = gen_xmlNodePtr(n_prev, 0); + cur = gen_xmlNodePtr_in(n_cur, 1); - ret_val = xmlAddNextSibling(cur, elem); - if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; } + ret_val = xmlAddNextSibling(prev, cur); + if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; } desret_xmlNodePtr(ret_val); call_tests++; - des_xmlNodePtr(n_cur, cur, 0); - des_xmlNodePtr_in(n_elem, elem, 1); + des_xmlNodePtr(n_prev, prev, 0); + des_xmlNodePtr_in(n_cur, cur, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlAddNextSibling", xmlMemBlocks() - mem_base); test_ret++; + printf(" %d", n_prev); printf(" %d", n_cur); - printf(" %d", n_elem); printf("\n"); } } @@ -17752,30 +18358,30 @@ test_xmlAddPrevSibling(void) { #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) int mem_base; xmlNodePtr ret_val; - xmlNodePtr cur; /* the child node */ + xmlNodePtr next; /* the target node */ + int n_next; + xmlNodePtr cur; /* the new node */ int n_cur; - xmlNodePtr elem; /* the new node */ - int n_elem; - for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { - for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) { + for (n_next = 0;n_next < gen_nb_xmlNodePtr;n_next++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) { mem_base = xmlMemBlocks(); - cur = gen_xmlNodePtr(n_cur, 0); - elem = gen_xmlNodePtr_in(n_elem, 1); + next = gen_xmlNodePtr(n_next, 0); + cur = gen_xmlNodePtr_in(n_cur, 1); - ret_val = xmlAddPrevSibling(cur, elem); - if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; } + ret_val = xmlAddPrevSibling(next, cur); + if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; } desret_xmlNodePtr(ret_val); call_tests++; - des_xmlNodePtr(n_cur, cur, 0); - des_xmlNodePtr_in(n_elem, elem, 1); + des_xmlNodePtr(n_next, next, 0); + des_xmlNodePtr_in(n_cur, cur, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlAddPrevSibling", xmlMemBlocks() - mem_base); test_ret++; + printf(" %d", n_next); printf(" %d", n_cur); - printf(" %d", n_elem); printf("\n"); } } @@ -17793,30 +18399,30 @@ test_xmlAddSibling(void) { int mem_base; xmlNodePtr ret_val; - xmlNodePtr cur; /* the child node */ + xmlNodePtr node; /* the target node */ + int n_node; + xmlNodePtr cur; /* the new node */ int n_cur; - xmlNodePtr elem; /* the new node */ - int n_elem; - for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) { - for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) { + for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { + for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) { mem_base = xmlMemBlocks(); - cur = gen_xmlNodePtr(n_cur, 0); - elem = gen_xmlNodePtr_in(n_elem, 1); + node = gen_xmlNodePtr(n_node, 0); + cur = gen_xmlNodePtr_in(n_cur, 1); - ret_val = xmlAddSibling(cur, elem); - if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; } + ret_val = xmlAddSibling(node, cur); + if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; } desret_xmlNodePtr(ret_val); call_tests++; - des_xmlNodePtr(n_cur, cur, 0); - des_xmlNodePtr_in(n_elem, elem, 1); + des_xmlNodePtr(n_node, node, 0); + des_xmlNodePtr_in(n_cur, cur, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlAddSibling", xmlMemBlocks() - mem_base); test_ret++; + printf(" %d", n_node); printf(" %d", n_cur); - printf(" %d", n_elem); printf("\n"); } } @@ -18785,7 +19391,7 @@ test_xmlCopyDtd(void) { #if defined(LIBXML_TREE_ENABLED) int mem_base; xmlDtdPtr ret_val; - xmlDtdPtr dtd; /* the dtd */ + xmlDtdPtr dtd; /* the DTD */ int n_dtd; for (n_dtd = 0;n_dtd < gen_nb_xmlDtdPtr;n_dtd++) { @@ -19033,13 +19639,13 @@ test_xmlCreateIntSubset(void) { int mem_base; xmlDtdPtr ret_val; - xmlDocPtr doc; /* the document pointer */ + xmlDocPtr doc; /* the document pointer (optional) */ int n_doc; - const xmlChar * name; /* the DTD name */ + const xmlChar * name; /* the DTD name (optional) */ int n_name; - const xmlChar * ExternalID; /* the external (PUBLIC) ID */ + const xmlChar * ExternalID; /* the external (PUBLIC) ID (optional) */ int n_ExternalID; - const xmlChar * SystemID; /* the system ID */ + const xmlChar * SystemID; /* the system ID (optional) */ int n_SystemID; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20153,6 +20759,16 @@ test_xmlGetNsList(void) { } +static int +test_xmlGetNsListSafe(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlGetNsProp(void) { int test_ret = 0; @@ -20434,11 +21050,11 @@ test_xmlNewCDataBlock(void) { int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* the target document (optional) */ int n_doc; - const xmlChar * content; /* the CDATA block content content */ + const xmlChar * content; /* raw text content (optional) */ int n_content; - int len; /* the length of the block */ + int len; /* size of text content */ int n_len; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20483,9 +21099,9 @@ test_xmlNewCharRef(void) { int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* the target document (optional) */ int n_doc; - const xmlChar * name; /* the char ref string, starting with # or "&# ... ;" */ + const xmlChar * name; /* the entity name */ int n_name; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20526,11 +21142,11 @@ test_xmlNewChild(void) { xmlNodePtr ret_val; xmlNodePtr parent; /* the parent node */ int n_parent; - xmlNsPtr ns; /* a namespace if any */ + xmlNsPtr ns; /* a namespace (optional) */ int n_ns; const xmlChar * name; /* the name of the child */ int n_name; - const xmlChar * content; /* the XML content of the child if any. */ + const xmlChar * content; /* text content with XML references (optional) */ int n_content; for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { @@ -20579,7 +21195,7 @@ test_xmlNewComment(void) { int mem_base; xmlNodePtr ret_val; - const xmlChar * content; /* the comment content */ + const xmlChar * content; /* the comment content (optional) */ int n_content; for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { @@ -20611,7 +21227,7 @@ test_xmlNewDoc(void) { int mem_base; xmlDocPtr ret_val; - const xmlChar * version; /* xmlChar string giving the version of XML "1.0" */ + const xmlChar * version; /* XML version string like "1.0" (optional) */ int n_version; for (n_version = 0;n_version < gen_nb_const_xmlChar_ptr;n_version++) { @@ -20683,7 +21299,7 @@ test_xmlNewDocFragment(void) { #if defined(LIBXML_TREE_ENABLED) int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the document owning the fragment */ + xmlDocPtr doc; /* the target document (optional) */ int n_doc; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20716,13 +21332,13 @@ test_xmlNewDocNode(void) { int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* the target document */ int n_doc; - xmlNsPtr ns; /* namespace if any */ + xmlNsPtr ns; /* namespace (optional) */ int n_ns; const xmlChar * name; /* the node name */ int n_name; - const xmlChar * content; /* the XML text content if any */ + const xmlChar * content; /* text content with XML references (optional) */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20769,13 +21385,13 @@ test_xmlNewDocNodeEatName(void) { int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* the target document */ int n_doc; - xmlNsPtr ns; /* namespace if any */ + xmlNsPtr ns; /* namespace (optional) */ int n_ns; xmlChar * name; /* the node name */ int n_name; - const xmlChar * content; /* the XML text content if any */ + const xmlChar * content; /* text content with XML references (optional) */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20822,11 +21438,11 @@ test_xmlNewDocPI(void) { int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the target document */ + xmlDocPtr doc; /* the target document (optional) */ int n_doc; - const xmlChar * name; /* the processing instruction name */ + const xmlChar * name; /* the processing instruction target */ int n_name; - const xmlChar * content; /* the PI content */ + const xmlChar * content; /* the PI content (optional) */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20868,11 +21484,11 @@ test_xmlNewDocProp(void) { int mem_base; xmlAttrPtr ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* the target document (optional) */ int n_doc; const xmlChar * name; /* the name of the attribute */ int n_name; - const xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* attribute value with XML references (optional) */ int n_value; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20916,13 +21532,13 @@ test_xmlNewDocRawNode(void) { #ifdef LIBXML_TREE_ENABLED int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* the target document */ int n_doc; - xmlNsPtr ns; /* namespace if any */ + xmlNsPtr ns; /* namespace (optional) */ int n_ns; const xmlChar * name; /* the node name */ int n_name; - const xmlChar * content; /* the text content if any */ + const xmlChar * content; /* raw text content (optional) */ int n_content; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -20971,9 +21587,9 @@ test_xmlNewDocText(void) { int mem_base; xmlNodePtr ret_val; - const xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the target document */ int n_doc; - const xmlChar * content; /* the text content */ + const xmlChar * content; /* raw text content (optional) */ int n_content; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -21010,11 +21626,11 @@ test_xmlNewDocTextLen(void) { int mem_base; xmlNodePtr ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* the target document */ int n_doc; - const xmlChar * content; /* the text content */ + const xmlChar * content; /* raw text content (optional) */ int n_content; - int len; /* the text len. */ + int len; /* size of text content */ int n_len; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -21059,13 +21675,13 @@ test_xmlNewDtd(void) { int mem_base; xmlDtdPtr ret_val; - xmlDocPtr doc; /* the document pointer */ + xmlDocPtr doc; /* the document pointer (optional) */ int n_doc; - const xmlChar * name; /* the DTD name */ + const xmlChar * name; /* the DTD name (optional) */ int n_name; - const xmlChar * ExternalID; /* the external ID */ + const xmlChar * ExternalID; /* the external ID (optional) */ int n_ExternalID; - const xmlChar * SystemID; /* the system ID */ + const xmlChar * SystemID; /* the system ID (optional) */ int n_SystemID; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -21112,7 +21728,7 @@ test_xmlNewNode(void) { int mem_base; xmlNodePtr ret_val; - xmlNsPtr ns; /* namespace if any */ + xmlNsPtr ns; /* namespace (optional) */ int n_ns; const xmlChar * name; /* the node name */ int n_name; @@ -21151,7 +21767,7 @@ test_xmlNewNodeEatName(void) { int mem_base; xmlNodePtr ret_val; - xmlNsPtr ns; /* namespace if any */ + xmlNsPtr ns; /* namespace (optional) */ int n_ns; xmlChar * name; /* the node name */ int n_name; @@ -21190,11 +21806,11 @@ test_xmlNewNs(void) { int mem_base; xmlNsPtr ret_val; - xmlNodePtr node; /* the element carrying the namespace */ + xmlNodePtr node; /* the element carrying the namespace (optional) */ int n_node; const xmlChar * href; /* the URI associated */ int n_href; - const xmlChar * prefix; /* the prefix for the namespace */ + const xmlChar * prefix; /* the prefix for the namespace (optional) */ int n_prefix; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21237,13 +21853,13 @@ test_xmlNewNsProp(void) { int mem_base; xmlAttrPtr ret_val; - xmlNodePtr node; /* the holding node */ + xmlNodePtr node; /* the parent node (optional) */ int n_node; - xmlNsPtr ns; /* the namespace */ + xmlNsPtr ns; /* the namespace (optional) */ int n_ns; - const xmlChar * name; /* the name of the attribute */ + const xmlChar * name; /* the local name of the attribute */ int n_name; - const xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute (optional) */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21290,13 +21906,13 @@ test_xmlNewNsPropEatName(void) { int mem_base; xmlAttrPtr ret_val; - xmlNodePtr node; /* the holding node */ + xmlNodePtr node; /* the parent node (optional) */ int n_node; - xmlNsPtr ns; /* the namespace */ + xmlNsPtr ns; /* the namespace (optional) */ int n_ns; - xmlChar * name; /* the name of the attribute */ + xmlChar * name; /* the local name of the attribute */ int n_name; - const xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute (optional) */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21343,9 +21959,9 @@ test_xmlNewPI(void) { int mem_base; xmlNodePtr ret_val; - const xmlChar * name; /* the processing instruction name */ + const xmlChar * name; /* the processing instruction target */ int n_name; - const xmlChar * content; /* the PI content */ + const xmlChar * content; /* the PI content (optional) */ int n_content; for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { @@ -21384,11 +22000,11 @@ test_xmlNewProp(void) { #ifdef LIBXML_TREE_ENABLED int mem_base; xmlAttrPtr ret_val; - xmlNodePtr node; /* the holding node */ + xmlNodePtr node; /* the parent node (optional) */ int n_node; const xmlChar * name; /* the name of the attribute */ int n_name; - const xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* the value of the attribute (optional) */ int n_value; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -21432,9 +22048,9 @@ test_xmlNewReference(void) { int mem_base; xmlNodePtr ret_val; - const xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* the target document (optional) */ int n_doc; - const xmlChar * name; /* the reference name, or the reference string with & and ; */ + const xmlChar * name; /* the entity name */ int n_name; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -21471,7 +22087,7 @@ test_xmlNewText(void) { int mem_base; xmlNodePtr ret_val; - const xmlChar * content; /* the text content */ + const xmlChar * content; /* raw text content (optional) */ int n_content; for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { @@ -21507,11 +22123,11 @@ test_xmlNewTextChild(void) { xmlNodePtr ret_val; xmlNodePtr parent; /* the parent node */ int n_parent; - xmlNsPtr ns; /* a namespace if any */ + xmlNsPtr ns; /* a namespace (optional) */ int n_ns; const xmlChar * name; /* the name of the child */ int n_name; - const xmlChar * content; /* the text content of the child if any. */ + const xmlChar * content; /* raw text content of the child (optional) */ int n_content; for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) { @@ -21560,9 +22176,9 @@ test_xmlNewTextLen(void) { int mem_base; xmlNodePtr ret_val; - const xmlChar * content; /* the text content */ + const xmlChar * content; /* raw text content (optional) */ int n_content; - int len; /* the text len. */ + int len; /* size of text content */ int n_len; for (n_content = 0;n_content < gen_nb_const_xmlChar_ptr;n_content++) { @@ -21635,6 +22251,7 @@ test_xmlNodeAddContent(void) { int test_ret = 0; int mem_base; + int ret_val; xmlNodePtr cur; /* the node being modified */ int n_cur; const xmlChar * content; /* extra content */ @@ -21646,7 +22263,8 @@ test_xmlNodeAddContent(void) { cur = gen_xmlNodePtr(n_cur, 0); content = gen_const_xmlChar_ptr(n_content, 1); - xmlNodeAddContent(cur, content); + ret_val = xmlNodeAddContent(cur, content); + desret_int(ret_val); call_tests++; des_xmlNodePtr(n_cur, cur, 0); des_const_xmlChar_ptr(n_content, content, 1); @@ -21672,6 +22290,7 @@ test_xmlNodeAddContentLen(void) { int test_ret = 0; int mem_base; + int ret_val; xmlNodePtr cur; /* the node being modified */ int n_cur; const xmlChar * content; /* extra content */ @@ -21690,7 +22309,8 @@ test_xmlNodeAddContentLen(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - xmlNodeAddContentLen(cur, content, len); + ret_val = xmlNodeAddContentLen(cur, content, len); + desret_int(ret_val); call_tests++; des_xmlNodePtr(n_cur, cur, 0); des_const_xmlChar_ptr(n_content, content, 1); @@ -21882,6 +22502,59 @@ test_xmlNodeDumpOutput(void) { } +static int +test_xmlNodeGetAttrValue(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + const xmlNode * node; /* the node */ + int n_node; + const xmlChar * name; /* the attribute name */ + int n_name; + const xmlChar * nsUri; /* the URI of the namespace */ + int n_nsUri; + xmlChar ** out; /* the returned string */ + int n_out; + + for (n_node = 0;n_node < gen_nb_const_xmlNode_ptr;n_node++) { + for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) { + for (n_nsUri = 0;n_nsUri < gen_nb_const_xmlChar_ptr;n_nsUri++) { + for (n_out = 0;n_out < gen_nb_xmlChar_ptr_ptr;n_out++) { + mem_base = xmlMemBlocks(); + node = gen_const_xmlNode_ptr(n_node, 0); + name = gen_const_xmlChar_ptr(n_name, 1); + nsUri = gen_const_xmlChar_ptr(n_nsUri, 2); + out = gen_xmlChar_ptr_ptr(n_out, 3); + + ret_val = xmlNodeGetAttrValue(node, name, nsUri, out); + desret_int(ret_val); + call_tests++; + des_const_xmlNode_ptr(n_node, node, 0); + des_const_xmlChar_ptr(n_name, name, 1); + des_const_xmlChar_ptr(n_nsUri, nsUri, 2); + des_xmlChar_ptr_ptr(n_out, out, 3); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeGetAttrValue", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_node); + printf(" %d", n_name); + printf(" %d", n_nsUri); + printf(" %d", n_out); + printf("\n"); + } + } + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlNodeGetBase(void) { int test_ret = 0; @@ -21921,6 +22594,52 @@ test_xmlNodeGetBase(void) { } +static int +test_xmlNodeGetBaseSafe(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + const xmlDoc * doc; /* the document the node pertains to */ + int n_doc; + const xmlNode * cur; /* the node being checked */ + int n_cur; + xmlChar ** baseOut; /* pointer to base */ + int n_baseOut; + + for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { + for (n_cur = 0;n_cur < gen_nb_const_xmlNode_ptr;n_cur++) { + for (n_baseOut = 0;n_baseOut < gen_nb_xmlChar_ptr_ptr;n_baseOut++) { + mem_base = xmlMemBlocks(); + doc = gen_const_xmlDoc_ptr(n_doc, 0); + cur = gen_const_xmlNode_ptr(n_cur, 1); + baseOut = gen_xmlChar_ptr_ptr(n_baseOut, 2); + + ret_val = xmlNodeGetBaseSafe(doc, cur, baseOut); + desret_int(ret_val); + call_tests++; + des_const_xmlDoc_ptr(n_doc, doc, 0); + des_const_xmlNode_ptr(n_cur, cur, 1); + des_xmlChar_ptr_ptr(n_baseOut, baseOut, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlNodeGetBaseSafe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_doc); + printf(" %d", n_cur); + printf(" %d", n_baseOut); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlNodeGetContent(void) { int test_ret = 0; @@ -22056,11 +22775,11 @@ test_xmlNodeListGetRawString(void) { #if defined(LIBXML_TREE_ENABLED) int mem_base; xmlChar * ret_val; - const xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* a document (optional) */ int n_doc; - const xmlNode * list; /* a Node list */ + const xmlNode * list; /* a node list of attribute children (optional) */ int n_list; - int inLine; /* should we replace entity contents or show their external form */ + int inLine; /* whether entity references are substituted */ int n_inLine; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -22103,11 +22822,11 @@ test_xmlNodeListGetString(void) { int mem_base; xmlChar * ret_val; - xmlDocPtr doc; /* the document */ + xmlDocPtr doc; /* a document (optional) */ int n_doc; - const xmlNode * list; /* a Node list */ + const xmlNode * list; /* a node list of attribute children (optional) */ int n_list; - int inLine; /* should we replace entity contents or show their external form */ + int inLine; /* whether entity references are substituted */ int n_inLine; for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) { @@ -22149,6 +22868,7 @@ test_xmlNodeSetBase(void) { #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) int mem_base; + int ret_val; xmlNodePtr cur; /* the node being changed */ int n_cur; const xmlChar * uri; /* the new base URI */ @@ -22160,7 +22880,8 @@ test_xmlNodeSetBase(void) { cur = gen_xmlNodePtr(n_cur, 0); uri = gen_const_xmlChar_ptr(n_uri, 1); - xmlNodeSetBase(cur, uri); + ret_val = xmlNodeSetBase(cur, uri); + desret_int(ret_val); call_tests++; des_xmlNodePtr(n_cur, cur, 0); des_const_xmlChar_ptr(n_uri, uri, 1); @@ -22187,6 +22908,7 @@ test_xmlNodeSetContent(void) { int test_ret = 0; int mem_base; + int ret_val; xmlNodePtr cur; /* the node being modified */ int n_cur; const xmlChar * content; /* the new value of the content */ @@ -22198,7 +22920,8 @@ test_xmlNodeSetContent(void) { cur = gen_xmlNodePtr(n_cur, 0); content = gen_const_xmlChar_ptr(n_content, 1); - xmlNodeSetContent(cur, content); + ret_val = xmlNodeSetContent(cur, content); + desret_int(ret_val); call_tests++; des_xmlNodePtr(n_cur, cur, 0); des_const_xmlChar_ptr(n_content, content, 1); @@ -22225,6 +22948,7 @@ test_xmlNodeSetContentLen(void) { #if defined(LIBXML_TREE_ENABLED) int mem_base; + int ret_val; xmlNodePtr cur; /* the node being modified */ int n_cur; const xmlChar * content; /* the new value of the content */ @@ -22243,7 +22967,8 @@ test_xmlNodeSetContentLen(void) { (len > xmlStrlen(BAD_CAST content))) len = 0; - xmlNodeSetContentLen(cur, content, len); + ret_val = xmlNodeSetContentLen(cur, content, len); + desret_int(ret_val); call_tests++; des_xmlNodePtr(n_cur, cur, 0); des_const_xmlChar_ptr(n_content, content, 1); @@ -22274,6 +22999,7 @@ test_xmlNodeSetLang(void) { #if defined(LIBXML_TREE_ENABLED) int mem_base; + int ret_val; xmlNodePtr cur; /* the node being changed */ int n_cur; const xmlChar * lang; /* the language description */ @@ -22285,7 +23011,8 @@ test_xmlNodeSetLang(void) { cur = gen_xmlNodePtr(n_cur, 0); lang = gen_const_xmlChar_ptr(n_lang, 1); - xmlNodeSetLang(cur, lang); + ret_val = xmlNodeSetLang(cur, lang); + desret_int(ret_val); call_tests++; des_xmlNodePtr(n_cur, cur, 0); des_const_xmlChar_ptr(n_lang, lang, 1); @@ -22352,6 +23079,7 @@ test_xmlNodeSetSpacePreserve(void) { #if defined(LIBXML_TREE_ENABLED) int mem_base; + int ret_val; xmlNodePtr cur; /* the node being changed */ int n_cur; int val; /* the xml:space value ("0": default, 1: "preserve") */ @@ -22363,7 +23091,8 @@ test_xmlNodeSetSpacePreserve(void) { cur = gen_xmlNodePtr(n_cur, 0); val = gen_int(n_val, 1); - xmlNodeSetSpacePreserve(cur, val); + ret_val = xmlNodeSetSpacePreserve(cur, val); + desret_int(ret_val); call_tests++; des_xmlNodePtr(n_cur, cur, 0); des_int(n_val, val, 1); @@ -22514,7 +23243,7 @@ test_xmlReplaceNode(void) { xmlNodePtr ret_val; xmlNodePtr old; /* the old node */ int n_old; - xmlNodePtr cur; /* the node */ + xmlNodePtr cur; /* the node (optional) */ int n_cur; for (n_old = 0;n_old < gen_nb_xmlNodePtr;n_old++) { @@ -23046,7 +23775,7 @@ test_xmlSetNs(void) { int mem_base; xmlNodePtr node; /* a node in the document */ int n_node; - xmlNsPtr ns; /* a namespace pointer */ + xmlNsPtr ns; /* a namespace pointer (optional) */ int n_ns; for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) { @@ -23263,9 +23992,9 @@ test_xmlStringGetNodeList(void) { int mem_base; xmlNodePtr ret_val; - const xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* a document (optional) */ int n_doc; - const xmlChar * value; /* the value of the attribute */ + const xmlChar * value; /* an attribute value */ int n_value; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -23302,11 +24031,11 @@ test_xmlStringLenGetNodeList(void) { int mem_base; xmlNodePtr ret_val; - const xmlDoc * doc; /* the document */ + const xmlDoc * doc; /* a document (optional) */ int n_doc; - const xmlChar * value; /* the value of the text */ + const xmlChar * value; /* an attribute value */ int n_value; - int len; /* the length of the string value */ + int len; /* maximum length of the attribute value */ int n_len; for (n_doc = 0;n_doc < gen_nb_const_xmlDoc_ptr;n_doc++) { @@ -23783,7 +24512,7 @@ static int test_tree(void) { int test_ret = 0; - if (quiet == 0) printf("Testing tree : 144 of 170 functions ...\n"); + if (quiet == 0) printf("Testing tree : 146 of 173 functions ...\n"); test_ret += test_xmlAddChild(); test_ret += test_xmlAddChildList(); test_ret += test_xmlAddNextSibling(); @@ -23852,6 +24581,7 @@ test_tree(void) { test_ret += test_xmlGetNoNsProp(); test_ret += test_xmlGetNodePath(); test_ret += test_xmlGetNsList(); + test_ret += test_xmlGetNsListSafe(); test_ret += test_xmlGetNsProp(); test_ret += test_xmlGetProp(); test_ret += test_xmlHasNsProp(); @@ -23891,7 +24621,9 @@ test_tree(void) { test_ret += test_xmlNodeBufGetContent(); test_ret += test_xmlNodeDump(); test_ret += test_xmlNodeDumpOutput(); + test_ret += test_xmlNodeGetAttrValue(); test_ret += test_xmlNodeGetBase(); + test_ret += test_xmlNodeGetBaseSafe(); test_ret += test_xmlNodeGetContent(); test_ret += test_xmlNodeGetLang(); test_ret += test_xmlNodeGetSpacePreserve(); @@ -23984,6 +24716,52 @@ test_xmlBuildRelativeURI(void) { } +static int +test_xmlBuildRelativeURISafe(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + const xmlChar * URI; /* the URI reference under consideration */ + int n_URI; + const xmlChar * base; /* the base value */ + int n_base; + xmlChar ** valPtr; /* pointer to result URI */ + int n_valPtr; + + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + for (n_base = 0;n_base < gen_nb_const_xmlChar_ptr;n_base++) { + for (n_valPtr = 0;n_valPtr < gen_nb_xmlChar_ptr_ptr;n_valPtr++) { + mem_base = xmlMemBlocks(); + URI = gen_const_xmlChar_ptr(n_URI, 0); + base = gen_const_xmlChar_ptr(n_base, 1); + valPtr = gen_xmlChar_ptr_ptr(n_valPtr, 2); + + ret_val = xmlBuildRelativeURISafe(URI, base, valPtr); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URI, URI, 0); + des_const_xmlChar_ptr(n_base, base, 1); + des_xmlChar_ptr_ptr(n_valPtr, valPtr, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBuildRelativeURISafe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_base); + printf(" %d", n_valPtr); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlBuildURI(void) { int test_ret = 0; @@ -24023,6 +24801,52 @@ test_xmlBuildURI(void) { } +static int +test_xmlBuildURISafe(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + const xmlChar * URI; /* the URI instance found in the document */ + int n_URI; + const xmlChar * base; /* the base value */ + int n_base; + xmlChar ** valPtr; /* pointer to result URI */ + int n_valPtr; + + for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) { + for (n_base = 0;n_base < gen_nb_const_xmlChar_ptr;n_base++) { + for (n_valPtr = 0;n_valPtr < gen_nb_xmlChar_ptr_ptr;n_valPtr++) { + mem_base = xmlMemBlocks(); + URI = gen_const_xmlChar_ptr(n_URI, 0); + base = gen_const_xmlChar_ptr(n_base, 1); + valPtr = gen_xmlChar_ptr_ptr(n_valPtr, 2); + + ret_val = xmlBuildURISafe(URI, base, valPtr); + desret_int(ret_val); + call_tests++; + des_const_xmlChar_ptr(n_URI, URI, 0); + des_const_xmlChar_ptr(n_base, base, 1); + des_xmlChar_ptr_ptr(n_valPtr, valPtr, 2); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlBuildURISafe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_URI); + printf(" %d", n_base); + printf(" %d", n_valPtr); + printf("\n"); + } + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCanonicPath(void) { int test_ret = 0; @@ -24160,6 +24984,49 @@ test_xmlParseURIReference(void) { } +#define gen_nb_xmlURIPtr_ptr 1 +#define gen_xmlURIPtr_ptr(no, nr) NULL +#define des_xmlURIPtr_ptr(no, val, nr) + +static int +test_xmlParseURISafe(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + const char * str; /* the URI string to analyze */ + int n_str; + xmlURIPtr * uriOut; /* optional pointer to parsed URI */ + int n_uriOut; + + for (n_str = 0;n_str < gen_nb_filepath;n_str++) { + for (n_uriOut = 0;n_uriOut < gen_nb_xmlURIPtr_ptr;n_uriOut++) { + mem_base = xmlMemBlocks(); + str = gen_filepath(n_str, 0); + uriOut = gen_xmlURIPtr_ptr(n_uriOut, 1); + + ret_val = xmlParseURISafe(str, uriOut); + desret_int(ret_val); + call_tests++; + des_filepath(n_str, str, 0); + des_xmlURIPtr_ptr(n_uriOut, uriOut, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlParseURISafe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_str); + printf(" %d", n_uriOut); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlPathToURI(void) { int test_ret = 0; @@ -24345,15 +25212,18 @@ static int test_uri(void) { int test_ret = 0; - if (quiet == 0) printf("Testing uri : 10 of 15 functions ...\n"); + if (quiet == 0) printf("Testing uri : 13 of 18 functions ...\n"); test_ret += test_xmlBuildRelativeURI(); + test_ret += test_xmlBuildRelativeURISafe(); test_ret += test_xmlBuildURI(); + test_ret += test_xmlBuildURISafe(); test_ret += test_xmlCanonicPath(); test_ret += test_xmlCreateURI(); test_ret += test_xmlNormalizeURIPath(); test_ret += test_xmlParseURI(); test_ret += test_xmlParseURIRaw(); test_ret += test_xmlParseURIReference(); + test_ret += test_xmlParseURISafe(); test_ret += test_xmlPathToURI(); test_ret += test_xmlPrintURI(); test_ret += test_xmlSaveUri(); @@ -24524,6 +25394,45 @@ test_xmlAddID(void) { } +static int +test_xmlAddIDSafe(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlAttrPtr attr; /* the attribute holding the ID */ + int n_attr; + const xmlChar * value; /* the attribute (ID) value */ + int n_value; + + for (n_attr = 0;n_attr < gen_nb_xmlAttrPtr;n_attr++) { + for (n_value = 0;n_value < gen_nb_const_xmlChar_ptr;n_value++) { + mem_base = xmlMemBlocks(); + attr = gen_xmlAttrPtr(n_attr, 0); + value = gen_const_xmlChar_ptr(n_value, 1); + + ret_val = xmlAddIDSafe(attr, value); + desret_int(ret_val); + call_tests++; + des_xmlAttrPtr(n_attr, attr, 0); + des_const_xmlChar_ptr(n_value, value, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlAddIDSafe", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_attr); + printf(" %d", n_value); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlAddNotationDecl(void) { int test_ret = 0; @@ -26818,10 +27727,11 @@ static int test_valid(void) { int test_ret = 0; - if (quiet == 0) printf("Testing valid : 50 of 70 functions ...\n"); + if (quiet == 0) printf("Testing valid : 51 of 71 functions ...\n"); test_ret += test_xmlAddAttributeDecl(); test_ret += test_xmlAddElementDecl(); test_ret += test_xmlAddID(); + test_ret += test_xmlAddIDSafe(); test_ret += test_xmlAddNotationDecl(); test_ret += test_xmlAddRef(); test_ret += test_xmlCopyAttributeTable(); @@ -26885,6 +27795,47 @@ test_valid(void) { printf("Module valid: %d errors\n", test_ret); return(test_ret); } +#ifdef LIBXML_XINCLUDE_ENABLED + +#define gen_nb_xmlXIncludeCtxtPtr 1 +#define gen_xmlXIncludeCtxtPtr(no, nr) NULL +#define des_xmlXIncludeCtxtPtr(no, val, nr) +#endif + + +static int +test_xmlXIncludeGetLastError(void) { + int test_ret = 0; + +#if defined(LIBXML_XINCLUDE_ENABLED) + int mem_base; + int ret_val; + xmlXIncludeCtxtPtr ctxt; /* an XInclude processing context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlXIncludeCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlXIncludeCtxtPtr(n_ctxt, 0); + + ret_val = xmlXIncludeGetLastError(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlXIncludeCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlXIncludeGetLastError", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + static int test_xmlXIncludeNewContext(void) { @@ -27018,13 +27969,6 @@ test_xmlXIncludeProcessFlagsData(void) { return(test_ret); } -#ifdef LIBXML_XINCLUDE_ENABLED - -#define gen_nb_xmlXIncludeCtxtPtr 1 -#define gen_xmlXIncludeCtxtPtr(no, nr) NULL -#define des_xmlXIncludeCtxtPtr(no, val, nr) -#endif - static int test_xmlXIncludeProcessNode(void) { @@ -27190,6 +28134,16 @@ test_xmlXIncludeProcessTreeFlagsData(void) { } +static int +test_xmlXIncludeSetErrorHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlXIncludeSetFlags(void) { int test_ret = 0; @@ -27234,7 +28188,8 @@ static int test_xinclude(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xinclude : 8 of 10 functions ...\n"); + if (quiet == 0) printf("Testing xinclude : 9 of 12 functions ...\n"); + test_ret += test_xmlXIncludeGetLastError(); test_ret += test_xmlXIncludeNewContext(); test_ret += test_xmlXIncludeProcess(); test_ret += test_xmlXIncludeProcessFlags(); @@ -27243,6 +28198,7 @@ test_xinclude(void) { test_ret += test_xmlXIncludeProcessTree(); test_ret += test_xmlXIncludeProcessTreeFlags(); test_ret += test_xmlXIncludeProcessTreeFlagsData(); + test_ret += test_xmlXIncludeSetErrorHandler(); test_ret += test_xmlXIncludeSetFlags(); if (test_ret != 0) @@ -27290,7 +28246,7 @@ test_xmlAllocParserInputBuffer(void) { int mem_base; xmlParserInputBufferPtr ret_val; - xmlCharEncoding enc; /* the charset encoding if known */ + xmlCharEncoding enc; /* the charset encoding if known (deprecated) */ int n_enc; for (n_enc = 0;n_enc < gen_nb_xmlCharEncoding;n_enc++) { @@ -28334,7 +29290,7 @@ test_xmlParserInputBufferCreateFd(void) { xmlParserInputBufferPtr ret_val; int fd; /* a file descriptor number */ int n_fd; - xmlCharEncoding enc; /* the charset encoding if known */ + xmlCharEncoding enc; /* the charset encoding if known (deprecated) */ int n_enc; for (n_fd = 0;n_fd < gen_nb_int;n_fd++) { @@ -28374,7 +29330,7 @@ test_xmlParserInputBufferCreateFile(void) { xmlParserInputBufferPtr ret_val; FILE * file; /* a FILE* */ int n_file; - xmlCharEncoding enc; /* the charset encoding if known */ + xmlCharEncoding enc; /* the charset encoding if known (deprecated) */ int n_enc; for (n_file = 0;n_file < gen_nb_FILE_ptr;n_file++) { @@ -28464,7 +29420,7 @@ test_xmlParserInputBufferCreateMem(void) { int n_mem; int size; /* the length of the memory block */ int n_size; - xmlCharEncoding enc; /* the charset encoding if known */ + xmlCharEncoding enc; /* the charset encoding if known (deprecated) */ int n_enc; for (n_mem = 0;n_mem < gen_nb_const_char_ptr;n_mem++) { @@ -29318,6 +30274,16 @@ test_xmlCtxtResetLastError(void) { } +static int +test_xmlFormatError(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlGetLastError(void) { int test_ret = 0; @@ -29516,11 +30482,12 @@ static int test_xmlerror(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xmlerror : 7 of 17 functions ...\n"); + if (quiet == 0) printf("Testing xmlerror : 7 of 18 functions ...\n"); test_ret += test_initGenericErrorDefaultFunc(); test_ret += test_xmlCopyError(); test_ret += test_xmlCtxtGetLastError(); test_ret += test_xmlCtxtResetLastError(); + test_ret += test_xmlFormatError(); test_ret += test_xmlGetLastError(); test_ret += test_xmlParserError(); test_ret += test_xmlParserPrintFileContext(); @@ -30961,6 +31928,16 @@ test_xmlTextReaderGetErrorHandler(void) { } +static int +test_xmlTextReaderGetLastError(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + + static int test_xmlTextReaderGetParserColumnNumber(void) { int test_ret = 0; @@ -32642,7 +33619,7 @@ static int test_xmlreader(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xmlreader : 76 of 87 functions ...\n"); + if (quiet == 0) printf("Testing xmlreader : 76 of 88 functions ...\n"); test_ret += test_xmlNewTextReader(); test_ret += test_xmlNewTextReaderFilename(); test_ret += test_xmlReaderForDoc(); @@ -32675,6 +33652,7 @@ test_xmlreader(void) { test_ret += test_xmlTextReaderGetAttributeNo(); test_ret += test_xmlTextReaderGetAttributeNs(); test_ret += test_xmlTextReaderGetErrorHandler(); + test_ret += test_xmlTextReaderGetLastError(); test_ret += test_xmlTextReaderGetParserColumnNumber(); test_ret += test_xmlTextReaderGetParserLineNumber(); test_ret += test_xmlTextReaderGetParserProp(); @@ -33673,6 +34651,40 @@ test_xmlSaveDoc(void) { } +static int +test_xmlSaveFinish(void) { + int test_ret = 0; + +#if defined(LIBXML_OUTPUT_ENABLED) + int mem_base; + int ret_val; + xmlSaveCtxtPtr ctxt; /* a document saving context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlSaveCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); + + ret_val = xmlSaveFinish(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlSaveFinish", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + static int test_xmlSaveFlush(void) { int test_ret = 0; @@ -33903,9 +34915,10 @@ static int test_xmlsave(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xmlsave : 7 of 13 functions ...\n"); + if (quiet == 0) printf("Testing xmlsave : 8 of 14 functions ...\n"); test_ret += test_xmlSaveClose(); test_ret += test_xmlSaveDoc(); + test_ret += test_xmlSaveFinish(); test_ret += test_xmlSaveFlush(); test_ret += test_xmlSaveSetAttrEscape(); test_ret += test_xmlSaveSetEscape(); @@ -43139,6 +44152,40 @@ test_xmlNewTextWriterTree(void) { } +static int +test_xmlTextWriterClose(void) { + int test_ret = 0; + +#if defined(LIBXML_WRITER_ENABLED) + int mem_base; + int ret_val; + xmlTextWriterPtr writer; /* the xmlTextWriterPtr */ + int n_writer; + + for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) { + mem_base = xmlMemBlocks(); + writer = gen_xmlTextWriterPtr(n_writer, 0); + + ret_val = xmlTextWriterClose(writer); + desret_int(ret_val); + call_tests++; + des_xmlTextWriterPtr(n_writer, writer, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlTextWriterClose", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_writer); + printf("\n"); + } + } + function_tests++; +#endif + + return(test_ret); +} + + static int test_xmlTextWriterEndAttribute(void) { int test_ret = 0; @@ -45547,12 +46594,13 @@ static int test_xmlwriter(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xmlwriter : 52 of 80 functions ...\n"); + if (quiet == 0) printf("Testing xmlwriter : 53 of 81 functions ...\n"); test_ret += test_xmlNewTextWriter(); test_ret += test_xmlNewTextWriterFilename(); test_ret += test_xmlNewTextWriterMemory(); test_ret += test_xmlNewTextWriterPushParser(); test_ret += test_xmlNewTextWriterTree(); + test_ret += test_xmlTextWriterClose(); test_ret += test_xmlTextWriterEndAttribute(); test_ret += test_xmlTextWriterEndCDATA(); test_ret += test_xmlTextWriterEndComment(); @@ -46841,11 +47889,21 @@ test_xmlXPathSetContextNode(void) { return(test_ret); } + +static int +test_xmlXPathSetErrorHandler(void) { + int test_ret = 0; + + + /* missing type support */ + return(test_ret); +} + static int test_xpath(void) { int test_ret = 0; - if (quiet == 0) printf("Testing xpath : 32 of 40 functions ...\n"); + if (quiet == 0) printf("Testing xpath : 32 of 41 functions ...\n"); test_ret += test_xmlXPathCastBooleanToNumber(); test_ret += test_xmlXPathCastBooleanToString(); test_ret += test_xmlXPathCastNodeSetToBoolean(); @@ -46881,6 +47939,7 @@ test_xpath(void) { test_ret += test_xmlXPathObjectCopy(); test_ret += test_xmlXPathOrderDocElems(); test_ret += test_xmlXPathSetContextNode(); + test_ret += test_xmlXPathSetErrorHandler(); if (test_ret != 0) printf("Module xpath: %d errors\n", test_ret); @@ -47519,26 +48578,26 @@ test_xmlXPathErr(void) { int mem_base; xmlXPathParserContextPtr ctxt; /* a XPath parser context */ int n_ctxt; - int error; /* the error code */ - int n_error; + int code; /* the error code */ + int n_code; for (n_ctxt = 0;n_ctxt < gen_nb_xmlXPathParserContextPtr;n_ctxt++) { - for (n_error = 0;n_error < gen_nb_int;n_error++) { + for (n_code = 0;n_code < gen_nb_int;n_code++) { mem_base = xmlMemBlocks(); ctxt = gen_xmlXPathParserContextPtr(n_ctxt, 0); - error = gen_int(n_error, 1); + code = gen_int(n_code, 1); - xmlXPathErr(ctxt, error); + xmlXPathErr(ctxt, code); call_tests++; des_xmlXPathParserContextPtr(n_ctxt, ctxt, 0); - des_int(n_error, error, 1); + des_int(n_code, code, 1); xmlResetLastError(); if (mem_base != xmlMemBlocks()) { printf("Leak of %d blocks found in xmlXPathErr", xmlMemBlocks() - mem_base); test_ret++; printf(" %d", n_ctxt); - printf(" %d", n_error); + printf(" %d", n_code); printf("\n"); } } From 7a94fd0ba62663d68f81ce08d7d7c0f7b50c7bf6 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 12 Jun 2024 13:35:20 +0200 Subject: [PATCH 502/504] doc: Update documentation --- doc/devhelp/libxml2-HTMLparser.html | 182 +-- doc/devhelp/libxml2-SAX.html | 2 +- doc/devhelp/libxml2-SAX2.html | 2 +- doc/devhelp/libxml2-debugXML.html | 4 +- doc/devhelp/libxml2-encoding.html | 64 +- doc/devhelp/libxml2-entities.html | 54 +- doc/devhelp/libxml2-globals.html | 18 - doc/devhelp/libxml2-hash.html | 136 ++- doc/devhelp/libxml2-list.html | 8 +- doc/devhelp/libxml2-parser.html | 310 +++-- doc/devhelp/libxml2-parserInternals.html | 80 +- doc/devhelp/libxml2-pattern.html | 39 + doc/devhelp/libxml2-relaxng.html | 4 +- doc/devhelp/libxml2-tree.html | 700 ++++++----- doc/devhelp/libxml2-uri.html | 94 +- doc/devhelp/libxml2-valid.html | 76 +- doc/devhelp/libxml2-xinclude.html | 48 + doc/devhelp/libxml2-xmlIO.html | 74 +- doc/devhelp/libxml2-xmlerror.html | 40 +- doc/devhelp/libxml2-xmlexports.html | 23 +- doc/devhelp/libxml2-xmlmemory.html | 24 +- doc/devhelp/libxml2-xmlreader.html | 24 +- doc/devhelp/libxml2-xmlsave.html | 22 + doc/devhelp/libxml2-xmlschemas.html | 4 +- doc/devhelp/libxml2-xmlstring.html | 2 +- doc/devhelp/libxml2-xmlversion.html | 63 +- doc/devhelp/libxml2-xmlwriter.html | 23 + doc/devhelp/libxml2-xpath.html | 28 +- doc/devhelp/libxml2-xpathInternals.html | 8 +- doc/devhelp/libxml2.devhelp2 | 55 +- doc/libxml2-api.xml | 1348 +++++++++++++--------- doc/xmlcatalog.1 | 4 +- doc/xmllint.1 | 32 +- doc/xmllint.html | 15 +- 34 files changed, 2302 insertions(+), 1308 deletions(-) diff --git a/doc/devhelp/libxml2-HTMLparser.html b/doc/devhelp/libxml2-HTMLparser.html index 5b7865ffd..22942a88f 100644 --- a/doc/devhelp/libxml2-HTMLparser.html +++ b/doc/devhelp/libxml2-HTMLparser.html @@ -45,6 +45,7 @@

    Synopsis

    htmlParserCtxtPtr htmlCreateFileParserCtxt (const char * filename,
    const char * encoding); htmlParserCtxtPtr htmlCreateMemoryParserCtxt (const char * buffer,
    int size); htmlParserCtxtPtr htmlCreatePushParserCtxt (htmlSAXHandlerPtr sax,
    void * user_data,
    const char * chunk,
    int size,
    const char * filename,
    xmlCharEncoding enc); +htmlDocPtr htmlCtxtParseDocument (htmlParserCtxtPtr ctxt,
    xmlParserInputPtr input); htmlDocPtr htmlCtxtReadDoc (htmlParserCtxtPtr ctxt,
    const xmlChar * str,
    const char * URL,
    const char * encoding,
    int options); htmlDocPtr htmlCtxtReadFd (htmlParserCtxtPtr ctxt,
    int fd,
    const char * URL,
    const char * encoding,
    int options); htmlDocPtr htmlCtxtReadFile (htmlParserCtxtPtr ctxt,
    const char * filename,
    const char * encoding,
    int options); @@ -64,7 +65,7 @@

    Synopsis

    int htmlIsScriptAttribute (const xmlChar * name); htmlParserCtxtPtr htmlNewParserCtxt (void); htmlParserCtxtPtr htmlNewSAXParserCtxt (const htmlSAXHandler * sax,
    void * userData); -htmlStatus htmlNodeStatus (const htmlNodePtr node,
    int legacy); +htmlStatus htmlNodeStatus (htmlNodePtr node,
    int legacy); int htmlParseCharRef (htmlParserCtxtPtr ctxt); int htmlParseChunk (htmlParserCtxtPtr ctxt,
    const char * chunk,
    int size,
    int terminate); htmlDocPtr htmlParseDoc (const xmlChar * cur,
    const char * encoding); @@ -72,11 +73,11 @@

    Synopsis

    void htmlParseElement (htmlParserCtxtPtr ctxt); const htmlEntityDesc * htmlParseEntityRef (htmlParserCtxtPtr ctxt,
    const xmlChar ** str); htmlDocPtr htmlParseFile (const char * filename,
    const char * encoding); -htmlDocPtr htmlReadDoc (const xmlChar * cur,
    const char * URL,
    const char * encoding,
    int options); -htmlDocPtr htmlReadFd (int fd,
    const char * URL,
    const char * encoding,
    int options); +htmlDocPtr htmlReadDoc (const xmlChar * str,
    const char * url,
    const char * encoding,
    int options); +htmlDocPtr htmlReadFd (int fd,
    const char * url,
    const char * encoding,
    int options); htmlDocPtr htmlReadFile (const char * filename,
    const char * encoding,
    int options); -htmlDocPtr htmlReadIO (xmlInputReadCallback ioread,
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * URL,
    const char * encoding,
    int options); -htmlDocPtr htmlReadMemory (const char * buffer,
    int size,
    const char * URL,
    const char * encoding,
    int options); +htmlDocPtr htmlReadIO (xmlInputReadCallback ioread,
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * url,
    const char * encoding,
    int options); +htmlDocPtr htmlReadMemory (const char * buffer,
    int size,
    const char * url,
    const char * encoding,
    int options); htmlDocPtr htmlSAXParseDoc (const xmlChar * cur,
    const char * encoding,
    htmlSAXHandlerPtr sax,
    void * userData); htmlDocPtr htmlSAXParseFile (const char * filename,
    const char * encoding,
    htmlSAXHandlerPtr sax,
    void * userData); const htmlElemDesc * htmlTagLookup (const xmlChar * tag); @@ -295,6 +296,14 @@


    +Variable htmlDefaultSAXHandler

    +
    const xmlSAXHandlerV1 htmlDefaultSAXHandler;
    +
    +

    DEPRECATED: This handler is unused and will be removed from future versions. Default old SAX v1 handler for HTML, builds the DOM tree

    +
    +
    +
    +

    UTF8ToHtml ()

    int	UTF8ToHtml			(unsigned char * out, 
    int * outlen,
    const unsigned char * in,
    int * inlen)
    @@ -391,7 +400,7 @@

    htmlCreateFileParserCtxt ()

    htmlParserCtxtPtr	htmlCreateFileParserCtxt	(const char * filename, 
    const char * encoding)
    -

    Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

    +

    DEPRECATED: Use htmlNewParserCtxt and htmlCtxtReadFile. Create a parser context to read from a file. A non-NULL encoding overrides encoding declarations in the document. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

    @@ -401,11 +410,11 @@

    - + - +
    encoding:a free form C string describing the HTML document encoding, or NULLoptional encoding
    Returns:the new parser context or NULLthe new parser context or NULL if a memory allocation failed.
    @@ -416,7 +425,7 @@

    htmlCreateMemoryParserCtxt ()

    htmlParserCtxtPtr	htmlCreateMemoryParserCtxt	(const char * buffer, 
    int size)
    -

    Create a parser context for an HTML in-memory document.

    +

    DEPRECATED: Use htmlNewParserCtxt and htmlCtxtReadMemory. Create a parser context for an HTML in-memory document. The input buffer must not contain any terminating null bytes.

    @@ -441,21 +450,21 @@

    htmlCreatePushParserCtxt ()

    htmlParserCtxtPtr	htmlCreatePushParserCtxt	(htmlSAXHandlerPtr sax, 
    void * user_data,
    const char * chunk,
    int size,
    const char * filename,
    xmlCharEncoding enc)
    -

    Create a parser context for using the HTML parser in push mode The value of @filename is used for fetching external entities and error/warning reports.

    +

    Create a parser context for using the HTML parser in push mode.

    - + - + - + @@ -463,15 +472,40 @@

    - + - + - + + + +
    sax:a SAX handlera SAX handler (optional)
    user_data:The user data returned on SAX callbacksThe user data returned on SAX callbacks (optional)
    chunk:a pointer to an array of charsa pointer to an array of chars (optional)
    size:
    filename:an optional file name or URIonly used for error reporting (optional)
    enc:an optional encodingencoding (deprecated, pass XML_CHAR_ENCODING_NONE)
    Returns:the new parser context or NULLthe new parser context or NULL if a memory allocation failed.
    +
    +
    +
    +

    +htmlCtxtParseDocument ()

    +
    htmlDocPtr	htmlCtxtParseDocument	(htmlParserCtxtPtr ctxt, 
    xmlParserInputPtr input)
    +
    +

    Parse an HTML document and return the resulting document tree. Available since 2.13.0.

    +
    ++ + + + + + + + + + + +
    ctxt:an HTML parser context
    input:parser input
    Returns:the resulting document tree or NULL
    @@ -482,7 +516,7 @@

    htmlCtxtReadDoc ()

    htmlDocPtr	htmlCtxtReadDoc		(htmlParserCtxtPtr ctxt, 
    const xmlChar * str,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

    +

    Parse an HTML in-memory document and build a tree. See htmlCtxtUseOptions for details.

    @@ -496,15 +530,15 @@

    - + - + - + @@ -519,7 +553,7 @@

    htmlCtxtReadFd ()

    htmlDocPtr	htmlCtxtReadFd		(htmlParserCtxtPtr ctxt, 
    int fd,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML from a file descriptor and build a tree. This reuses the existing @ctxt parser context

    +

    Parse an HTML from a file descriptor and build a tree. See htmlCtxtUseOptions for details. NOTE that the file descriptor will not be closed when the context is freed or reset.

    URL:the base URL to use for the documentonly used for error reporting (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:a combination of htmlParserOption(s)a combination of htmlParserOptions
    Returns:
    @@ -533,15 +567,15 @@

    - + - + - + @@ -556,7 +590,7 @@

    htmlCtxtReadFile ()

    htmlDocPtr	htmlCtxtReadFile	(htmlParserCtxtPtr ctxt, 
    const char * filename,
    const char * encoding,
    int options)
    -

    parse an XML file from the filesystem or the network. This reuses the existing @ctxt parser context

    +

    Parse an HTML file from the filesystem, the network or a user-defined resource loader. See xmlNewInputURL and htmlCtxtUseOptions for details.

    URL:the base URL to use for the documentonly used for error reporting (optional)
    encoding:the document encoding, or NULLthe document encoding (optinal)
    options:a combination of htmlParserOption(s)a combination of htmlParserOptions
    Returns:
    @@ -570,11 +604,11 @@

    - + - + @@ -589,7 +623,7 @@

    htmlCtxtReadIO ()

    htmlDocPtr	htmlCtxtReadIO		(htmlParserCtxtPtr ctxt, 
    xmlInputReadCallback ioread,
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an HTML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context

    +

    Parse an HTML document from I/O functions and source and build a tree. See xmlNewInputIO and htmlCtxtUseOptions for details.

    encoding:the document encoding, or NULLthe document encoding (optional)
    options:a combination of htmlParserOption(s)a combination of htmlParserOptions
    Returns:
    @@ -634,7 +668,7 @@

    htmlCtxtReadMemory ()

    htmlDocPtr	htmlCtxtReadMemory	(htmlParserCtxtPtr ctxt, 
    const char * buffer,
    int size,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

    +

    Parse an HTML in-memory document and build a tree. The input buffer must not contain any terminating null bytes. See htmlCtxtUseOptions for details.

    @@ -652,15 +686,15 @@

    - + - + - + @@ -860,7 +894,7 @@

    htmlHandleOmittedElem ()

    int	htmlHandleOmittedElem		(int val)
    -

    Set and return the previous value for handling HTML omitted tags.

    +

    DEPRECATED: Use HTML_PARSE_NOIMPLIED Set and return the previous value for handling HTML omitted tags.

    URL:the base URL to use for the documentonly used for error reporting (optional)
    encoding:the document encoding, or NULLthe document encoding (optinal)
    options:a combination of htmlParserOption(s)a combination of htmlParserOptions
    Returns:
    @@ -935,7 +969,7 @@

    htmlNewParserCtxt ()

    htmlParserCtxtPtr	htmlNewParserCtxt	(void)
    -

    Allocate and initialize a new parser context.

    +

    Allocate and initialize a new HTML parser context. This can be used to parse HTML documents into DOM trees with functions like xmlCtxtReadFile or xmlCtxtReadMemory. See htmlCtxtUseOptions for parser options. See xmlCtxtSetErrorHandler for advanced error handling. See xmlNewInputURL, xmlNewInputMemory, xmlNewInputIO and similar functions for advanced input control. See htmlNewSAXParserCtxt for custom SAX parsers.

    @@ -950,7 +984,7 @@

    htmlNewSAXParserCtxt ()

    htmlParserCtxtPtr	htmlNewSAXParserCtxt	(const htmlSAXHandler * sax, 
    void * userData)
    -

    Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data.

    +

    Allocate and initialize a new HTML SAX parser context. If userData is NULL, the parser context will be passed as user data. Available since 2.11.0. If you want support older versions, it's best to invoke htmlNewParserCtxt and set ctxt->sax with struct assignment. Also see htmlNewParserCtxt.

    @@ -973,7 +1007,7 @@

    htmlNodeStatus ()

    -
    htmlStatus	htmlNodeStatus		(const htmlNodePtr node, 
    int legacy)
    +
    htmlStatus	htmlNodeStatus		(htmlNodePtr node, 
    int legacy)

    Checks whether the tree node is valid. Experimental (the author only uses the HTML enhancements in a SAX parser)

    @@ -1021,7 +1055,7 @@

    htmlParseChunk ()

    int	htmlParseChunk			(htmlParserCtxtPtr ctxt, 
    const char * chunk,
    int size,
    int terminate)
    -

    Parse a Chunk of memory

    +

    Parse a chunk of memory in push parser mode. Assumes that the parser context was initialized with htmlCreatePushParserCtxt. The last chunk, which will often be empty, must be marked with the @terminate flag. With the default SAX callbacks, the resulting document will be available in ctxt->myDoc. This pointer will not be freed by the library. If the document isn't well-formed, ctxt->myDoc is set to NULL.

    @@ -1031,11 +1065,11 @@

    - + - + @@ -1043,7 +1077,7 @@

    - +
    chunk:an char arraychunk of memory
    size:the size in byte of the chunksize of chunk in bytes
    terminate:
    Returns:zero if no error, the xmlParserErrors otherwise.an xmlParserErrors code (0 on success).
    @@ -1054,7 +1088,7 @@

    htmlParseDoc ()

    htmlDocPtr	htmlParseDoc		(const xmlChar * cur, 
    const char * encoding)
    -

    parse an HTML in-memory document and build a tree.

    +

    DEPRECATED: Use htmlReadDoc. Parse an HTML in-memory document and build a tree. This function uses deprecated global parser options.

    @@ -1065,7 +1099,7 @@

    - + @@ -1080,7 +1114,7 @@

    htmlParseDocument ()

    int	htmlParseDocument		(htmlParserCtxtPtr ctxt)
    -

    parse an HTML document (and build a tree if using the standard SAX interface).

    +

    Parse an HTML document and invoke the SAX handlers. This is useful if you're only interested in custom SAX callbacks. If you want a document tree, use htmlCtxtParseDocument.

    encoding:a free form C string describing the HTML document encoding, or NULLthe encoding (optional)
    Returns:
    @@ -1090,7 +1124,7 @@

    - +
    Returns:0, -1 in case of error. the parser context is augmented as a result of the parsing.0, -1 in case of error.
    @@ -1141,7 +1175,7 @@

    htmlParseFile ()

    htmlDocPtr	htmlParseFile		(const char * filename, 
    const char * encoding)
    -

    parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

    +

    Parse an HTML file and build a tree. See xmlNewInputURL for details.

    @@ -1151,7 +1185,7 @@

    - + @@ -1164,31 +1198,31 @@

    htmlReadDoc ()

    -
    htmlDocPtr	htmlReadDoc		(const xmlChar * cur, 
    const char * URL,
    const char * encoding,
    int options)
    +
    htmlDocPtr	htmlReadDoc		(const xmlChar * str, 
    const char * url,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree.

    +

    Convenience function to parse an HTML document from a zero-terminated string. See htmlCtxtReadDoc for details.

    encoding:a free form C string describing the HTML document encoding, or NULLencoding (optional)
    Returns:
    - + - - + + - + - + - +
    cur:str: a pointer to a zero terminated string
    URL:the base URL to use for the documenturl:only used for error reporting (optoinal)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:a combination of htmlParserOption(s)a combination of htmlParserOptions
    Returns:the resulting document treethe resulting document tree.
    @@ -1197,9 +1231,9 @@

    htmlReadFd ()

    -
    htmlDocPtr	htmlReadFd		(int fd, 
    const char * URL,
    const char * encoding,
    int options)
    +
    htmlDocPtr	htmlReadFd		(int fd, 
    const char * url,
    const char * encoding,
    int options)
    -

    parse an HTML from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the reader is closed or reset.

    +

    Convenience function to parse an HTML document from a file descriptor. NOTE that the file descriptor will not be closed when the context is freed or reset. See htmlCtxtReadFd for details.

    @@ -1208,8 +1242,8 @@

    - - + + @@ -1217,7 +1251,7 @@

    - + @@ -1232,7 +1266,7 @@

    htmlReadFile ()

    htmlDocPtr	htmlReadFile		(const char * filename, 
    const char * encoding,
    int options)
    -

    parse an XML file from the filesystem or the network.

    +

    Convenience function to parse an HTML file from the filesystem, the network or a global user-defined resource loader. See htmlCtxtReadFile for details.

    an open file descriptor
    URL:the base URL to use for the documenturl:only used for error reporting (optional)
    encoding:
    options:a combination of htmlParserOption(s)a combination of htmlParserOptions
    Returns:
    @@ -1242,15 +1276,15 @@

    - + - + - +
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:a combination of htmlParserOption(s)a combination of htmlParserOptions
    Returns:the resulting document treethe resulting document tree.
    @@ -1259,9 +1293,9 @@

    htmlReadIO ()

    -
    htmlDocPtr	htmlReadIO		(xmlInputReadCallback ioread, 
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * URL,
    const char * encoding,
    int options)
    +
    htmlDocPtr	htmlReadIO		(xmlInputReadCallback ioread, 
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * url,
    const char * encoding,
    int options)
    -

    parse an HTML document from I/O functions and source and build a tree.

    +

    Convenience function to parse an HTML document from I/O functions and context. See htmlCtxtReadIO for details.

    @@ -1271,19 +1305,19 @@

    - + - - + + - + @@ -1300,9 +1334,9 @@

    htmlReadMemory ()

    -
    htmlDocPtr	htmlReadMemory		(const char * buffer, 
    int size,
    const char * URL,
    const char * encoding,
    int options)
    +
    htmlDocPtr	htmlReadMemory		(const char * buffer, 
    int size,
    const char * url,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree.

    +

    Convenience function to parse an HTML document from memory. The input buffer must not contain any terminating null bytes. See htmlCtxtReadMemory for details.

    ioclose:an I/O close functionan I/O close function (optional)
    ioctx: an I/O handler
    URL:the base URL to use for the documenturl:only used for error reporting (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -1315,8 +1349,8 @@

    - - + + @@ -1383,7 +1417,7 @@

    - + diff --git a/doc/devhelp/libxml2-SAX.html b/doc/devhelp/libxml2-SAX.html index 632836c2e..612ab4e85 100644 --- a/doc/devhelp/libxml2-SAX.html +++ b/doc/devhelp/libxml2-SAX.html @@ -827,7 +827,7 @@

    setDocumentLocator ()

    void	setDocumentLocator		(void * ctx, 
    xmlSAXLocatorPtr loc)
    -

    Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case. DEPRECATED

    +

    Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case. DEPRECATED

    the size of the array
    URL:the base URL to use for the documenturl:only used for error reporting (optional)
    encoding:
    encoding:a free form C string describing the HTML document encoding, or NULLencoding (optional)
    sax:
    diff --git a/doc/devhelp/libxml2-SAX2.html b/doc/devhelp/libxml2-SAX2.html index 9d4e2c602..410229ce9 100644 --- a/doc/devhelp/libxml2-SAX2.html +++ b/doc/devhelp/libxml2-SAX2.html @@ -750,7 +750,7 @@

    xmlSAX2SetDocumentLocator ()

    void	xmlSAX2SetDocumentLocator	(void * ctx, 
    xmlSAXLocatorPtr loc)
    -

    Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case.

    +

    Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case.

    diff --git a/doc/devhelp/libxml2-debugXML.html b/doc/devhelp/libxml2-debugXML.html index e5939a6bb..ec134dc1c 100644 --- a/doc/devhelp/libxml2-debugXML.html +++ b/doc/devhelp/libxml2-debugXML.html @@ -38,7 +38,7 @@

    Synopsis

    void xmlDebugDumpString (FILE * output,
    const xmlChar * str); int xmlLsCountNode (xmlNodePtr node); void xmlLsOneNode (FILE * output,
    xmlNodePtr node); -void xmlShell (xmlDocPtr doc,
    char * filename,
    xmlShellReadlineFunc input,
    FILE * output); +void xmlShell (xmlDocPtr doc,
    const char * filename,
    xmlShellReadlineFunc input,
    FILE * output); int xmlShellBase (xmlShellCtxtPtr ctxt,
    char * arg,
    xmlNodePtr node,
    xmlNodePtr node2); int xmlShellCat (xmlShellCtxtPtr ctxt,
    char * arg,
    xmlNodePtr node,
    xmlNodePtr node2); typedef int xmlShellCmd (xmlShellCtxtPtr ctxt,
    char * arg,
    xmlNodePtr node,
    xmlNodePtr node2); @@ -460,7 +460,7 @@

    xmlShell ()

    -
    void	xmlShell			(xmlDocPtr doc, 
    char * filename,
    xmlShellReadlineFunc input,
    FILE * output)
    +
    void	xmlShell			(xmlDocPtr doc, 
    const char * filename,
    xmlShellReadlineFunc input,
    FILE * output)

    Implements the XML shell This allow to load, validate, view, modify and save a document using a environment similar to a UNIX commandline.

    diff --git a/doc/devhelp/libxml2-encoding.html b/doc/devhelp/libxml2-encoding.html index 39782478b..f656c169e 100644 --- a/doc/devhelp/libxml2-encoding.html +++ b/doc/devhelp/libxml2-encoding.html @@ -44,7 +44,9 @@

    Synopsis

    const char * xmlGetCharEncodingName (xmlCharEncoding enc); const char * xmlGetEncodingAlias (const char * alias); void xmlInitCharEncodingHandlers (void); +int xmlLookupCharEncodingHandler (xmlCharEncoding enc,
    xmlCharEncodingHandler ** out); xmlCharEncodingHandlerPtrxmlNewCharEncodingHandler (const char * name,
    xmlCharEncodingInputFunc input,
    xmlCharEncodingOutputFunc output); +int xmlOpenCharEncodingHandler (const char * name,
    int output,
    xmlCharEncodingHandler ** out); xmlCharEncodingxmlParseCharEncoding (const char * name); void xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); @@ -457,7 +459,7 @@

    xmlFindCharEncodingHandler ()

    xmlCharEncodingHandlerPtr	xmlFindCharEncodingHandler	(const char * name)
    -

    Search in the registered set the handler able to read/write that encoding or create a new one.

    +

    DEPRECATED: Use xmlOpenCharEncodingHandler which has better error reporting.

    @@ -467,7 +469,7 @@

    - +
    Returns:the handler or NULL if not foundthe handler or NULL if no handler was found or an error occurred.
    @@ -478,7 +480,7 @@

    xmlGetCharEncodingHandler ()

    xmlCharEncodingHandlerPtr	xmlGetCharEncodingHandler	(xmlCharEncoding enc)
    -

    Search in the registered set the handler able to read/write that encoding.

    +

    DEPRECATED: Use xmlLookupCharEncodingHandler which has better error reporting.

    @@ -488,7 +490,7 @@

    - +
    Returns:the handler or NULL if not foundthe handler or NULL if no handler was found or an error occurred.
    @@ -546,6 +548,31 @@


    +xmlLookupCharEncodingHandler ()

    +
    int	xmlLookupCharEncodingHandler	(xmlCharEncoding enc, 
    xmlCharEncodingHandler ** out)
    +
    +

    Find or create a handler matching the encoding. If no default or registered handler could be found, try to create a handler using iconv or ICU if supported. The handler must be closed with xmlCharEncCloseFunc. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + +
    enc:an xmlCharEncoding value.
    out:pointer to result
    Returns:an xmlParserErrors error code.
    +
    +
    +
    +

    xmlNewCharEncodingHandler ()

    xmlCharEncodingHandlerPtr	xmlNewCharEncodingHandler	(const char * name, 
    xmlCharEncodingInputFunc input,
    xmlCharEncodingOutputFunc output)
    @@ -575,6 +602,35 @@


    +xmlOpenCharEncodingHandler ()

    +
    int	xmlOpenCharEncodingHandler	(const char * name, 
    int output,
    xmlCharEncodingHandler ** out)
    +
    +

    Find or create a handler matching the encoding. If no default or registered handler could be found, try to create a handler using iconv or ICU if supported. The handler must be closed with xmlCharEncCloseFunc. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + +
    name:a string describing the char encoding.
    output:boolean, use handler for output
    out:pointer to result
    Returns:an xmlParserErrors error code.
    +
    +
    +
    +

    xmlParseCharEncoding ()

    xmlCharEncoding	xmlParseCharEncoding	(const char * name)
    diff --git a/doc/devhelp/libxml2-entities.html b/doc/devhelp/libxml2-entities.html index e21cbcf64..243f35444 100644 --- a/doc/devhelp/libxml2-entities.html +++ b/doc/devhelp/libxml2-entities.html @@ -27,6 +27,7 @@

    Synopsis

    typedef enum xmlEntityType; xmlEntityPtr xmlAddDocEntity (xmlDocPtr doc,
    const xmlChar * name,
    int type,
    const xmlChar * ExternalID,
    const xmlChar * SystemID,
    const xmlChar * content); xmlEntityPtr xmlAddDtdEntity (xmlDocPtr doc,
    const xmlChar * name,
    int type,
    const xmlChar * ExternalID,
    const xmlChar * SystemID,
    const xmlChar * content); +int xmlAddEntity (xmlDocPtr doc,
    int extSubset,
    const xmlChar * name,
    int type,
    const xmlChar * ExternalID,
    const xmlChar * SystemID,
    const xmlChar * content,
    xmlEntityPtr * out); void xmlCleanupPredefinedEntities (void); xmlEntitiesTablePtr xmlCopyEntitiesTable (xmlEntitiesTablePtr table); xmlEntitiesTablePtr xmlCreateEntitiesTable (void); @@ -166,6 +167,55 @@


    +xmlAddEntity ()

    +
    int	xmlAddEntity			(xmlDocPtr doc, 
    int extSubset,
    const xmlChar * name,
    int type,
    const xmlChar * ExternalID,
    const xmlChar * SystemID,
    const xmlChar * content,
    xmlEntityPtr * out)
    +
    +

    Register a new entity for this document. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    doc:the document
    extSubset:add to the external or internal subset
    name:the entity name
    type:the entity type XML_xxx_yyy_ENTITY
    ExternalID:the entity external ID if available
    SystemID:the entity system ID if available
    content:the entity content
    out:pointer to resulting entity (optional)
    Returns:an xmlParserErrors error code.
    +
    +
    +
    +

    xmlCleanupPredefinedEntities ()

    void	xmlCleanupPredefinedEntities	(void)
    @@ -345,12 +395,12 @@

    xmlFreeEntity ()

    void	xmlFreeEntity			(xmlEntityPtr entity)
    -

    +

    Frees the entity.

    - +
    entity:an entity
    diff --git a/doc/devhelp/libxml2-globals.html b/doc/devhelp/libxml2-globals.html index dbd7b3e9b..bf8bbd171 100644 --- a/doc/devhelp/libxml2-globals.html +++ b/doc/devhelp/libxml2-globals.html @@ -24,9 +24,7 @@

    globals

    Synopsis

    typedef struct _xmlGlobalState xmlGlobalState;
     typedef xmlGlobalState * xmlGlobalStatePtr;
    -void	xmlCleanupGlobals		(void);
     xmlGlobalStatePtr	xmlGetGlobalState	(void);
    -void	xmlInitGlobals			(void);
     void	xmlInitializeGlobalState	(xmlGlobalStatePtr gs);
     
    @@ -54,14 +52,6 @@


    -xmlCleanupGlobals ()

    -
    void	xmlCleanupGlobals		(void)
    -
    -

    DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.

    -
    -
    -
    -

    xmlGetGlobalState ()

    xmlGlobalStatePtr	xmlGetGlobalState	(void)
    @@ -77,14 +67,6 @@


    -xmlInitGlobals ()

    -
    void	xmlInitGlobals			(void)
    -
    -

    DEPRECATED: Alias for xmlInitParser.

    -
    -
    -
    -

    xmlInitializeGlobalState ()

    void	xmlInitializeGlobalState	(xmlGlobalStatePtr gs)
    diff --git a/doc/devhelp/libxml2-hash.html b/doc/devhelp/libxml2-hash.html index 4452739e8..026356518 100644 --- a/doc/devhelp/libxml2-hash.html +++ b/doc/devhelp/libxml2-hash.html @@ -25,11 +25,15 @@

    Synopsis

    #define XML_CAST_FPTR(fptr);
     typedef struct _xmlHashTable xmlHashTable;
     typedef xmlHashTable * xmlHashTablePtr;
    +int	xmlHashAdd			(xmlHashTablePtr hash, 
    const xmlChar * key,
    void * payload); +int xmlHashAdd2 (xmlHashTablePtr hash,
    const xmlChar * key,
    const xmlChar * key2,
    void * payload); +int xmlHashAdd3 (xmlHashTablePtr hash,
    const xmlChar * key,
    const xmlChar * key2,
    const xmlChar * key3,
    void * payload); int xmlHashAddEntry (xmlHashTablePtr hash,
    const xmlChar * key,
    void * payload); int xmlHashAddEntry2 (xmlHashTablePtr hash,
    const xmlChar * key,
    const xmlChar * key2,
    void * payload); int xmlHashAddEntry3 (xmlHashTablePtr hash,
    const xmlChar * key,
    const xmlChar * key2,
    const xmlChar * key3,
    void * payload); typedef void * xmlHashCopier (void * payload,
    const xmlChar * name); xmlHashTablePtr xmlHashCopy (xmlHashTablePtr hash,
    xmlHashCopier copy); +xmlHashTablePtr xmlHashCopySafe (xmlHashTablePtr hash,
    xmlHashCopier copyFunc,
    xmlHashDeallocator deallocFunc); xmlHashTablePtr xmlHashCreate (int size); xmlHashTablePtr xmlHashCreateDict (int size,
    xmlDictPtr dict); typedef void xmlHashDeallocator (void * payload,
    const xmlChar * name); @@ -199,10 +203,109 @@


    +xmlHashAdd ()

    +
    int	xmlHashAdd			(xmlHashTablePtr hash, 
    const xmlChar * key,
    void * payload)
    +
    +

    Add a hash table entry. If an entry with this key already exists, payload will not be updated and 0 is returned. This return value can't be distinguished from out-of-memory errors, so this function should be used with care. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + +
    hash:hash table
    key:string key
    payload:pointer to the payload
    Returns:1 on success, 0 if an entry exists and -1 in case of error.
    +
    +
    +
    +

    +xmlHashAdd2 ()

    +
    int	xmlHashAdd2			(xmlHashTablePtr hash, 
    const xmlChar * key,
    const xmlChar * key2,
    void * payload)
    +
    +

    Add a hash table entry with two strings as key. See xmlHashAdd. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + + + + + +
    hash:hash table
    key:first string key
    key2:second string key
    payload:pointer to the payload
    Returns:1 on success, 0 if an entry exists and -1 in case of error.
    +
    +
    +
    +

    +xmlHashAdd3 ()

    +
    int	xmlHashAdd3			(xmlHashTablePtr hash, 
    const xmlChar * key,
    const xmlChar * key2,
    const xmlChar * key3,
    void * payload)
    +
    +

    Add a hash table entry with three strings as key. See xmlHashAdd. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + + + + + + + + + +
    hash:hash table
    key:first string key
    key2:second string key
    key3:third string key
    payload:pointer to the payload
    Returns:1 on success, 0 if an entry exists and -1 in case of error.
    +
    +
    +
    +

    xmlHashAddEntry ()

    int	xmlHashAddEntry			(xmlHashTablePtr hash, 
    const xmlChar * key,
    void * payload)
    -

    Add a hash table entry. If an entry with this key already exists, payload will not be updated and -1 is returned. This return value can't be distinguished from out-of-memory errors, so this function should be used with care.

    +

    Add a hash table entry. If an entry with this key already exists, payload will not be updated and -1 is returned. This return value can't be distinguished from out-of-memory errors, so this function should be used with care. NOTE: This function doesn't allow to distinguish malloc failures from existing entries. Use xmlHashAdd instead.

    @@ -301,7 +404,7 @@

    xmlHashCopy ()

    xmlHashTablePtr	xmlHashCopy		(xmlHashTablePtr hash, 
    xmlHashCopier copy)
    -

    Copy the hash @table using @copy to copy payloads.

    +

    DEPRECATED: Leaks memory in error case. Copy the hash table using @copy to copy payloads.

    @@ -323,6 +426,35 @@


    +xmlHashCopySafe ()

    +
    xmlHashTablePtr	xmlHashCopySafe		(xmlHashTablePtr hash, 
    xmlHashCopier copyFunc,
    xmlHashDeallocator deallocFunc)
    +
    +

    Copy the hash table using @copyFunc to copy payloads. Available since 2.13.0.

    +

    ++ + + + + + + + + + + + + + + + + + +
    hash:hash table
    copyFunc:copier function for items in the hash
    deallocFunc:deallocation function in case of errors
    Returns:the new table or NULL if a memory allocation failed.
    +
    +
    +
    +

    xmlHashCreate ()

    xmlHashTablePtr	xmlHashCreate		(int size)
    diff --git a/doc/devhelp/libxml2-list.html b/doc/devhelp/libxml2-list.html index 649f97a8c..6d188020d 100644 --- a/doc/devhelp/libxml2-list.html +++ b/doc/devhelp/libxml2-list.html @@ -29,12 +29,12 @@

    Synopsis

    void * xmlLinkGetData (xmlLinkPtr lk); int xmlListAppend (xmlListPtr l,
    void * data); void xmlListClear (xmlListPtr l); -int xmlListCopy (xmlListPtr cur,
    const xmlListPtr old); +int xmlListCopy (xmlListPtr cur,
    xmlListPtr old); xmlListPtr xmlListCreate (xmlListDeallocator deallocator,
    xmlListDataCompare compare); typedef int xmlListDataCompare (const void * data0,
    const void * data1); typedef void xmlListDeallocator (xmlLinkPtr lk); void xmlListDelete (xmlListPtr l); -xmlListPtr xmlListDup (const xmlListPtr old); +xmlListPtr xmlListDup (xmlListPtr old); int xmlListEmpty (xmlListPtr l); xmlLinkPtr xmlListEnd (xmlListPtr l); xmlLinkPtr xmlListFront (xmlListPtr l); @@ -226,7 +226,7 @@

    xmlListCopy ()

    -
    int	xmlListCopy			(xmlListPtr cur, 
    const xmlListPtr old)
    +
    int	xmlListCopy			(xmlListPtr cur, 
    xmlListPtr old)

    Move all the element from the old list in the new list

    @@ -291,7 +291,7 @@

    xmlListDup ()

    -
    xmlListPtr	xmlListDup		(const xmlListPtr old)
    +
    xmlListPtr	xmlListDup		(xmlListPtr old)

    Duplicate the list

    diff --git a/doc/devhelp/libxml2-parser.html b/doc/devhelp/libxml2-parser.html index f18176f57..5813629c2 100644 --- a/doc/devhelp/libxml2-parser.html +++ b/doc/devhelp/libxml2-parser.html @@ -22,11 +22,8 @@

    parser

    Author(s): Daniel Veillard

    Synopsis

    -
    #define XML_COMPLETE_ATTRS;
    -#define XML_DEFAULT_VERSION;
    -#define XML_DETECT_IDS;
    +
    #define XML_DEFAULT_VERSION;
     #define XML_SAX2_MAGIC;
    -#define XML_SKIP_IDS;
     typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
     typedef enum xmlFeature;
     typedef enum xmlParserInputState;
    @@ -71,12 +68,14 @@ 

    Synopsis

    typedef void unparsedEntityDeclSAXFunc (void * ctx,
    const xmlChar * name,
    const xmlChar * publicId,
    const xmlChar * systemId,
    const xmlChar * notationName); typedef void warningSAXFunc (void * ctx,
    const char * msg,
    ... ...); long xmlByteConsumed (xmlParserCtxtPtr ctxt); +void xmlCleanupGlobals (void); void xmlCleanupParser (void); void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); void xmlClearParserCtxt (xmlParserCtxtPtr ctxt); xmlParserCtxtPtr xmlCreateDocParserCtxt (const xmlChar * str); xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
    void * user_data,
    xmlInputReadCallback ioread,
    xmlInputCloseCallback ioclose,
    void * ioctx,
    xmlCharEncoding enc); xmlParserCtxtPtr xmlCreatePushParserCtxt (xmlSAXHandlerPtr sax,
    void * user_data,
    const char * chunk,
    int size,
    const char * filename); +xmlDocPtr xmlCtxtParseDocument (xmlParserCtxtPtr ctxt,
    xmlParserInputPtr input); xmlDocPtr xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
    const xmlChar * str,
    const char * URL,
    const char * encoding,
    int options); xmlDocPtr xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
    int fd,
    const char * URL,
    const char * encoding,
    int options); xmlDocPtr xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
    const char * filename,
    const char * encoding,
    int options); @@ -84,7 +83,9 @@

    Synopsis

    xmlDocPtr xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
    const char * buffer,
    int size,
    const char * URL,
    const char * encoding,
    int options); void xmlCtxtReset (xmlParserCtxtPtr ctxt); int xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
    const char * chunk,
    int size,
    const char * filename,
    const char * encoding); +void xmlCtxtSetErrorHandler (xmlParserCtxtPtr ctxt,
    xmlStructuredErrorFunc handler,
    void * data); void xmlCtxtSetMaxAmplification (xmlParserCtxtPtr ctxt,
    unsigned maxAmpl); +int xmlCtxtSetOptions (xmlParserCtxtPtr ctxt,
    int options); int xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
    int options); typedef xmlParserInputPtr xmlExternalEntityLoader (const char * URL,
    const char * ID,
    xmlParserCtxtPtr context); void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); @@ -93,31 +94,32 @@

    Synopsis

    int xmlGetFeaturesList (int * len,
    const char ** result); int xmlHasFeature (xmlFeature feature); xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax,
    xmlParserInputBufferPtr input,
    xmlCharEncoding enc); +void xmlInitGlobals (void); void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); void xmlInitParser (void); int xmlInitParserCtxt (xmlParserCtxtPtr ctxt); int xmlKeepBlanksDefault (int val); int xmlLineNumbersDefault (int val); xmlParserInputPtr xmlLoadExternalEntity (const char * URL,
    const char * ID,
    xmlParserCtxtPtr ctxt); -xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
    xmlParserInputBufferPtr input,
    xmlCharEncoding enc); +xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
    xmlParserInputBufferPtr buf,
    xmlCharEncoding enc); xmlParserCtxtPtr xmlNewParserCtxt (void); xmlParserCtxtPtr xmlNewSAXParserCtxt (const xmlSAXHandler * sax,
    void * userData); int xmlParseBalancedChunkMemory (xmlDocPtr doc,
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * string,
    xmlNodePtr * lst); -int xmlParseBalancedChunkMemoryRecover (xmlDocPtr doc,
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * string,
    xmlNodePtr * lst,
    int recover); +int xmlParseBalancedChunkMemoryRecover (xmlDocPtr doc,
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * string,
    xmlNodePtr * listOut,
    int recover); int xmlParseChunk (xmlParserCtxtPtr ctxt,
    const char * chunk,
    int size,
    int terminate); -int xmlParseCtxtExternalEntity (xmlParserCtxtPtr ctx,
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * lst); +int xmlParseCtxtExternalEntity (xmlParserCtxtPtr ctxt,
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * listOut); xmlDtdPtr xmlParseDTD (const xmlChar * ExternalID,
    const xmlChar * SystemID); xmlDocPtr xmlParseDoc (const xmlChar * cur); int xmlParseDocument (xmlParserCtxtPtr ctxt); xmlDocPtr xmlParseEntity (const char * filename); int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); -int xmlParseExternalEntity (xmlDocPtr doc,
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * lst); +int xmlParseExternalEntity (xmlDocPtr doc,
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * list); xmlDocPtr xmlParseFile (const char * filename); xmlParserErrors xmlParseInNodeContext (xmlNodePtr node,
    const char * data,
    int datalen,
    int options,
    xmlNodePtr * lst); xmlDocPtr xmlParseMemory (const char * buffer,
    int size); -void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
    const xmlParserNodeInfoPtr info); -const xmlParserNodeInfo * xmlParserFindNodeInfo (const xmlParserCtxtPtr ctx,
    const xmlNodePtr node); -unsigned long xmlParserFindNodeInfoIndex (const xmlParserNodeInfoSeqPtr seq,
    const xmlNodePtr node); +void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
    xmlParserNodeInfoPtr info); +const xmlParserNodeInfo * xmlParserFindNodeInfo (xmlParserCtxtPtr ctx,
    xmlNodePtr node); +unsigned long xmlParserFindNodeInfoIndex (xmlParserNodeInfoSeqPtr seq,
    xmlNodePtr node); typedef void xmlParserInputDeallocate (xmlChar * str); int xmlParserInputGrow (xmlParserInputPtr in,
    int len); int xmlParserInputRead (xmlParserInputPtr in,
    int len); @@ -126,7 +128,7 @@

    Synopsis

    xmlDocPtr xmlReadFd (int fd,
    const char * URL,
    const char * encoding,
    int options); xmlDocPtr xmlReadFile (const char * filename,
    const char * encoding,
    int options); xmlDocPtr xmlReadIO (xmlInputReadCallback ioread,
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * URL,
    const char * encoding,
    int options); -xmlDocPtr xmlReadMemory (const char * buffer,
    int size,
    const char * URL,
    const char * encoding,
    int options); +xmlDocPtr xmlReadMemory (const char * buffer,
    int size,
    const char * url,
    const char * encoding,
    int options); xmlDocPtr xmlRecoverDoc (const xmlChar * cur); xmlDocPtr xmlRecoverFile (const char * filename); xmlDocPtr xmlRecoverMemory (const char * buffer,
    int size); @@ -160,14 +162,6 @@

    Details

    -Macro XML_COMPLETE_ATTRS

    -
    #define XML_COMPLETE_ATTRS;
    -
    -

    Bit in the loadsubset context field to tell to do complete the elements attributes lists with the ones defaulted from the DTDs. Use it to initialize xmlLoadExtDtdDefaultValue.

    -
    -
    -
    -

    Macro XML_DEFAULT_VERSION

    #define XML_DEFAULT_VERSION;
     
    @@ -176,14 +170,6 @@


    -Macro XML_DETECT_IDS

    -
    #define XML_DETECT_IDS;
    -
    -

    Bit in the loadsubset context field to tell to do ID/REFs lookups. Use it to initialize xmlLoadExtDtdDefaultValue.

    -
    -
    -
    -

    Macro XML_SAX2_MAGIC

    #define XML_SAX2_MAGIC;
     
    @@ -192,14 +178,6 @@


    -Macro XML_SKIP_IDS

    -
    #define XML_SKIP_IDS;
    -
    -

    Bit in the loadsubset context field to tell to not do ID/REFs registration. Used to initialize xmlLoadExtDtdDefaultValue in some special cases.

    -
    -
    -
    -

    Structure xmlAttrHashBucket

    struct _xmlAttrHashBucket {
     The content of this structure is not made public by the API.
    @@ -241,7 +219,7 @@ 

    XML_WITH_MODULES = 27 XML_WITH_DEBUG = 28 XML_WITH_DEBUG_MEM = 29 - XML_WITH_DEBUG_RUN = 30 + XML_WITH_DEBUG_RUN = 30 /* unused */ XML_WITH_ZLIB = 31 XML_WITH_ICU = 32 XML_WITH_LZMA = 33 @@ -372,7 +350,8 @@

    XML_PARSE_HUGE = 524288 /* relax any hardcoded limit from the parser */ XML_PARSE_OLDSAX = 1048576 /* parse using SAX2 interface before 2.7.0 */ XML_PARSE_IGNORE_ENC = 2097152 /* ignore internal document encoding hint */ - XML_PARSE_BIG_LINES = 4194304 /* Store big lines numbers in text PSVI field */ + XML_PARSE_BIG_LINES = 4194304 /* Store big lines numbers in text PSVI field */ + XML_PARSE_NO_XXE = 8388608 /* disable loading of external content */ };

    @@ -1058,7 +1037,7 @@

    Function type setDocumentLocatorSAXFunc

    void	setDocumentLocatorSAXFunc	(void * ctx, 
    xmlSAXLocatorPtr loc)
    -

    Receive the document locator at startup, actually xmlDefaultSAXLocator. Everything is available on the context, so this is useless in our case.

    +

    Receive the document locator at startup, actually xmlDefaultSAXLocator. Everything is available on the context, so this is useless in our case.

    @@ -1267,6 +1246,38 @@


    +Variable oldXMLWDcompatibility

    +
    const int oldXMLWDcompatibility;
    +
    +

    Global setting, DEPRECATED.

    +
    +
    +
    +

    +Variable xmlDefaultSAXHandler

    +
    const xmlSAXHandlerV1 xmlDefaultSAXHandler;
    +
    +

    DEPRECATED: This handler is unused and will be removed from future versions. Default SAX version1 handler for XML, builds the DOM tree

    +
    +
    +
    +

    +Variable xmlDefaultSAXLocator

    +
    const xmlSAXLocator xmlDefaultSAXLocator;
    +
    +

    DEPRECATED: Don't use The default SAX Locator { getPublicId, getSystemId, getLineNumber, getColumnNumber}

    +
    +
    +
    +

    +Variable xmlParserDebugEntities

    +
    const int xmlParserDebugEntities;
    +
    +

    DEPRECATED: Don't use Global setting, asking the parser to print out debugging information. while handling entities. Disabled by default

    +
    +
    +
    +

    Variable xmlParserVersion

    const char * const xmlParserVersion;
     
    @@ -1296,6 +1307,14 @@


    +xmlCleanupGlobals ()

    +
    void	xmlCleanupGlobals		(void)
    +
    +

    DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.

    +
    +
    +
    +

    xmlCleanupParser ()

    void	xmlCleanupParser		(void)
    @@ -1365,11 +1384,11 @@

    - + - + @@ -1377,7 +1396,7 @@

    - + @@ -1385,7 +1404,7 @@

    - + @@ -1400,33 +1419,58 @@

    xmlCreatePushParserCtxt ()

    xmlParserCtxtPtr	xmlCreatePushParserCtxt	(xmlSAXHandlerPtr sax, 
    void * user_data,
    const char * chunk,
    int size,
    const char * filename)
    -

    Create a parser context for using the XML parser in push mode. If @buffer and @size are non-NULL, the data is used to detect the encoding. The remaining characters will be parsed so they don't need to be fed in again through xmlParseChunk. To allow content encoding detection, @size should be >= 4 The value of @filename is used for fetching external entities and error/warning reports.

    +

    Create a parser context for using the XML parser in push mode. See xmlParseChunk. Passing an initial chunk is useless and deprecated. @filename is used as base URI to fetch external entities and for error reports.

    sax:a SAX handlera SAX handler (optional)
    user_data:The user data returned on SAX callbacksuser data for SAX callbacks (optional)
    ioread:
    ioclose:an I/O close functionan I/O close function (optional)
    ioctx:
    enc:the charset encoding if knownthe charset encoding if known (deprecated)
    Returns:
    - + - + - + - + - + - + + + +
    sax:a SAX handlera SAX handler (optional)
    user_data:The user data returned on SAX callbacksuser data for SAX callbacks (optional)
    chunk:a pointer to an array of charsinitial chunk (optional, deprecated)
    size:number of chars in the arraysize of initial chunk in bytes
    filename:an optional file name or URIfile name or URI (optional)
    Returns:the new parser context or NULLthe new parser context or NULL in case of error.
    +
    +
    +
    +

    +xmlCtxtParseDocument ()

    +
    xmlDocPtr	xmlCtxtParseDocument	(xmlParserCtxtPtr ctxt, 
    xmlParserInputPtr input)
    +
    +

    Parse an XML document and return the resulting document tree. Takes ownership of the input object. Available since 2.13.0.

    +
    ++ + + + + + + + + + + +
    ctxt:an XML parser context
    input:parser input
    Returns:the resulting document tree or NULL
    @@ -1437,7 +1481,7 @@

    xmlCtxtReadDoc ()

    xmlDocPtr	xmlCtxtReadDoc		(xmlParserCtxtPtr ctxt, 
    const xmlChar * str,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

    +

    Parse an XML in-memory document and build a tree. @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details.

    @@ -1451,11 +1495,11 @@

    - + - + @@ -1475,7 +1519,7 @@

    xmlCtxtReadFd ()

    xmlDocPtr	xmlCtxtReadFd		(xmlParserCtxtPtr ctxt, 
    int fd,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML from a file descriptor and build a tree. This reuses the existing @ctxt parser context NOTE that the file descriptor will not be closed when the reader is closed or reset.

    +

    Parse an XML document from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the context is freed or reset. @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details.

    URL:the base URL to use for the documentbase URL (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -1489,11 +1533,11 @@

    - + - + @@ -1513,7 +1557,7 @@

    xmlCtxtReadFile ()

    xmlDocPtr	xmlCtxtReadFile		(xmlParserCtxtPtr ctxt, 
    const char * filename,
    const char * encoding,
    int options)
    -

    parse an XML file from the filesystem or the network. This reuses the existing @ctxt parser context

    +

    Parse an XML file from the filesystem, the network or a user-defined resource loader. See xmlNewInputURL and xmlCtxtUseOptions for details.

    URL:the base URL to use for the documentbase URL (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -1527,7 +1571,7 @@

    - + @@ -1547,7 +1591,7 @@

    xmlCtxtReadIO ()

    xmlDocPtr	xmlCtxtReadIO		(xmlParserCtxtPtr ctxt, 
    xmlInputReadCallback ioread,
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context

    +

    parse an XML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details.

    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -1593,7 +1637,7 @@

    xmlCtxtReadMemory ()

    xmlDocPtr	xmlCtxtReadMemory	(xmlParserCtxtPtr ctxt, 
    const char * buffer,
    int size,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

    +

    Parse an XML in-memory document and build a tree. The input buffer must not contain a terminating null byte. @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details.

    @@ -1611,11 +1655,11 @@

    - + - + @@ -1684,6 +1728,31 @@


    +xmlCtxtSetErrorHandler ()

    +
    void	xmlCtxtSetErrorHandler		(xmlParserCtxtPtr ctxt, 
    xmlStructuredErrorFunc handler,
    void * data)
    +
    +

    Register a callback function that will be called on errors and warnings. If handler is NULL, the error handler will be deactivated. This is the recommended way to collect errors from the parser and takes precedence over all other error reporting mechanisms. These are (in order of precedence): - per-context structured handler (xmlCtxtSetErrorHandler) - per-context structured "serror" SAX handler - global structured handler (xmlSetStructuredErrorFunc) - per-context generic "error" and "warning" SAX handlers - global generic handler (xmlSetGenericErrorFunc) - print to stderr Available since 2.13.0.

    +

    URL:the base URL to use for the documentbase URL (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    ++ + + + + + + + + + + + + + +
    ctxt:an XML parser context
    handler:error handler
    data:data for error handler
    +
    +
    +
    +

    xmlCtxtSetMaxAmplification ()

    void	xmlCtxtSetMaxAmplification	(xmlParserCtxtPtr ctxt, 
    unsigned maxAmpl)
    @@ -1705,10 +1774,35 @@


    +xmlCtxtSetOptions ()

    +
    int	xmlCtxtSetOptions		(xmlParserCtxtPtr ctxt, 
    int options)
    +
    +

    Applies the options to the parser context. Unset options are cleared. Available since 2.13.0. With older versions, you can use xmlCtxtUseOptions. XML_PARSE_RECOVER Enable "recovery" mode which allows non-wellformed documents. How this mode behaves exactly is unspecified and may change without further notice. Use of this feature is DISCOURAGED. XML_PARSE_NOENT Despite the confusing name, this option enables substitution of entities. The resulting tree won't contain any entity reference nodes. This option also enables loading of external entities (both general and parameter entities) which is dangerous. If you process untrusted data, it's recommended to set the XML_PARSE_NO_XXE option to disable loading of external entities. XML_PARSE_DTDLOAD Enables loading of an external DTD and the loading and substitution of external parameter entities. Has no effect if XML_PARSE_NO_XXE is set. XML_PARSE_DTDATTR Adds default attributes from the DTD to the result document. Implies XML_PARSE_DTDLOAD, but loading of external content can be disabled with XML_PARSE_NO_XXE. XML_PARSE_DTDVALID This option enables DTD validation which requires to load external DTDs and external entities (both general and parameter entities) unless XML_PARSE_NO_XXE was set. XML_PARSE_NO_XXE Disables loading of external DTDs or entities. XML_PARSE_NOERROR Disable error and warning reports to the error handlers. Errors are still accessible with xmlCtxtGetLastError. XML_PARSE_NOWARNING Disable warning reports. XML_PARSE_PEDANTIC Enable some pedantic warnings. XML_PARSE_NOBLANKS Remove some text nodes containing only whitespace from the result document. Which nodes are removed depends on DTD element declarations or a conservative heuristic. The reindenting feature of the serialization code relies on this option to be set when parsing. Use of this option is DISCOURAGED. XML_PARSE_SAX1 Always invoke the deprecated SAX1 startElement and endElement handlers. This option is DEPRECATED. XML_PARSE_NONET Disable network access with the builtin HTTP and FTP clients. XML_PARSE_NODICT Create a document without interned strings, making all strings separate memory allocations. XML_PARSE_NSCLEAN Remove redundant namespace declarations from the result document. XML_PARSE_NOCDATA Output normal text nodes instead of CDATA nodes. XML_PARSE_COMPACT Store small strings directly in the node struct to save memory. XML_PARSE_OLD10 Use old Name productions from before XML 1.0 Fifth Edition. This options is DEPRECATED. XML_PARSE_HUGE Relax some internal limits. Maximum size of text nodes, tags, comments, processing instructions, CDATA sections, entity values normal: 10M huge: 1B Maximum size of names, system literals, pubid literals normal: 50K huge: 10M Maximum nesting depth of elements normal: 256 huge: 2048 Maximum nesting depth of entities normal: 20 huge: 40 XML_PARSE_OLDSAX Enable an unspecified legacy mode for SAX parsers. This option is DEPRECATED. XML_PARSE_IGNORE_ENC Ignore the encoding in the XML declaration. This option is mostly unneeded these days. The only effect is to enforce UTF-8 decoding of ASCII-like data. XML_PARSE_BIG_LINES Enable reporting of line numbers larger than 65535.

    +
    ++ + + + + + + + + + + + + + +
    ctxt:an XML parser context
    options:a bitmask of xmlParserOption values
    Returns:0 in case of success, the set of unknown or unimplemented options in case of error.
    +
    +
    +
    +

    xmlCtxtUseOptions ()

    int	xmlCtxtUseOptions		(xmlParserCtxtPtr ctxt, 
    int options)
    -

    Applies the options to the parser context

    +

    DEPRECATED: Use xmlCtxtSetOptions. Applies the options to the parser context. The following options are never cleared and can only be enabled: XML_PARSE_NOERROR XML_PARSE_NOWARNING XML_PARSE_NONET XML_PARSE_NSCLEAN XML_PARSE_NOCDATA XML_PARSE_COMPACT XML_PARSE_OLD10 XML_PARSE_HUGE XML_PARSE_OLDSAX XML_PARSE_IGNORE_ENC XML_PARSE_BIG_LINES

    @@ -1865,6 +1959,14 @@


    +xmlInitGlobals ()

    +
    void	xmlInitGlobals			(void)
    +
    +

    DEPRECATED: Alias for xmlInitParser.

    +
    +
    +
    +

    xmlInitNodeInfoSeq ()

    void	xmlInitNodeInfoSeq		(xmlParserNodeInfoSeqPtr seq)
    @@ -1954,7 +2056,7 @@

    xmlLoadExternalEntity ()

    xmlParserInputPtr	xmlLoadExternalEntity	(const char * URL, 
    const char * ID,
    xmlParserCtxtPtr ctxt)
    -

    Load an external entity, note that the use of this function for unparsed entities may generate problems

    +

    @@ -1981,7 +2083,7 @@

    xmlNewIOInputStream ()

    -
    xmlParserInputPtr	xmlNewIOInputStream	(xmlParserCtxtPtr ctxt, 
    xmlParserInputBufferPtr input,
    xmlCharEncoding enc)
    +
    xmlParserInputPtr	xmlNewIOInputStream	(xmlParserCtxtPtr ctxt, 
    xmlParserInputBufferPtr buf,
    xmlCharEncoding enc)

    Create a new input stream structure encapsulating the @input into a stream suitable for the parser.

    @@ -1992,8 +2094,8 @@

    - - + + @@ -2027,7 +2129,7 @@

    xmlNewSAXParserCtxt ()

    xmlParserCtxtPtr	xmlNewSAXParserCtxt	(const xmlSAXHandler * sax, 
    void * userData)
    -

    Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data.

    +

    Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data. Available since 2.11.0. If you want support older versions, it's best to invoke xmlNewParserCtxt and set ctxt->sax with struct assignment.

    an XML parser context
    input:an I/O Inputbuf:an input buffer
    enc:
    @@ -2091,9 +2193,9 @@

    xmlParseBalancedChunkMemoryRecover ()

    -
    int	xmlParseBalancedChunkMemoryRecover	(xmlDocPtr doc, 
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * string,
    xmlNodePtr * lst,
    int recover)
    +
    int	xmlParseBalancedChunkMemoryRecover	(xmlDocPtr doc, 
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * string,
    xmlNodePtr * listOut,
    int recover)
    -

    Parse a well-balanced chunk of an XML document called by the parser The allowed sequence for the Well Balanced Chunk is the one defined by the content production in the XML grammar: [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*

    +

    Parse a well-balanced chunk of an XML document The allowed sequence for the Well Balanced Chunk is the one defined by the content production in the XML grammar: [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*

    @@ -2118,7 +2220,7 @@

    - + @@ -2127,7 +2229,7 @@

    - +
    the input string in UTF8 or ISO-Latin (zero terminated)
    lst:listOut: the return value for the set of parsed nodes
    Returns:0 if the chunk is well balanced, -1 in case of args problem and the parser error code otherwise In case recover is set to 1, the nodelist will not be empty even if the parsed chunk is not well balanced, assuming the parsing succeeded to some extent.0 if the chunk is well balanced, or thehe parser error code otherwise. In case recover is set to 1, the nodelist will not be empty even if the parsed chunk is not well balanced, assuming the parsing succeeded to some extent.
    @@ -2138,7 +2240,7 @@

    xmlParseChunk ()

    int	xmlParseChunk			(xmlParserCtxtPtr ctxt, 
    const char * chunk,
    int size,
    int terminate)
    -

    Parse a Chunk of memory

    +

    Parse a chunk of memory in push parser mode. Assumes that the parser context was initialized with xmlCreatePushParserCtxt. The last chunk, which will often be empty, must be marked with the @terminate flag. With the default SAX callbacks, the resulting document will be available in ctxt->myDoc. This pointer will not be freed by the library. If the document isn't well-formed, ctxt->myDoc is set to NULL. The push parser doesn't support recovery mode.

    @@ -2148,11 +2250,11 @@

    - + - + @@ -2160,7 +2262,7 @@

    - +
    chunk:an char arraychunk of memory
    size:the size in byte of the chunksize of chunk in bytes
    terminate:
    Returns:zero if no error, the xmlParserErrors otherwise.an xmlParserErrors code (0 on success).
    @@ -2169,14 +2271,14 @@

    xmlParseCtxtExternalEntity ()

    -
    int	xmlParseCtxtExternalEntity	(xmlParserCtxtPtr ctx, 
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * lst)
    +
    int	xmlParseCtxtExternalEntity	(xmlParserCtxtPtr ctxt, 
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * listOut)

    Parse an external general entity within an existing parsing context An external general parsed entity is well-formed if it matches the production labeled extParsedEnt. [78] extParsedEnt ::= TextDecl? content

    - + @@ -2188,7 +2290,7 @@

    - + @@ -2251,7 +2353,7 @@

    xmlParseDocument ()

    int	xmlParseDocument		(xmlParserCtxtPtr ctxt)
    -

    parse an XML document (and build a tree if using the standard SAX interface). [1] document ::= prolog element Misc* [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?

    +

    Parse an XML document and invoke the SAX handlers. This is useful if you're only interested in custom SAX callbacks. If you want a document tree, use xmlCtxtParseDocument.

    ctx:ctxt: the existing parsing context
    the System ID for the entity to load
    lst:listOut: the return value for the set of parsed nodes
    @@ -2261,7 +2363,7 @@

    - +
    Returns:0, -1 in case of error. the parser context is augmented as a result of the parsing.0, -1 in case of error.
    @@ -2312,9 +2414,9 @@

    xmlParseExternalEntity ()

    -
    int	xmlParseExternalEntity		(xmlDocPtr doc, 
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * lst)
    +
    int	xmlParseExternalEntity		(xmlDocPtr doc, 
    xmlSAXHandlerPtr sax,
    void * user_data,
    int depth,
    const xmlChar * URL,
    const xmlChar * ID,
    xmlNodePtr * list)
    -

    Parse an external general entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt. [78] extParsedEnt ::= TextDecl? content

    +

    DEPRECATED: Use xmlParseCtxtExternalEntity. Parse an external general entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt. [78] extParsedEnt ::= TextDecl? content

    @@ -2343,7 +2445,7 @@

    - + @@ -2442,7 +2544,7 @@

    xmlParserAddNodeInfo ()

    -
    void	xmlParserAddNodeInfo		(xmlParserCtxtPtr ctxt, 
    const xmlParserNodeInfoPtr info)
    +
    void	xmlParserAddNodeInfo		(xmlParserCtxtPtr ctxt, 
    xmlParserNodeInfoPtr info)

    DEPRECATED: Don't use. Insert node info record into the sorted sequence

    the System ID for the entity to load
    lst:list: the return value for the set of parsed nodes
    @@ -2463,7 +2565,7 @@

    xmlParserFindNodeInfo ()

    -
    const xmlParserNodeInfo *	xmlParserFindNodeInfo	(const xmlParserCtxtPtr ctx, 
    const xmlNodePtr node)
    +
    const xmlParserNodeInfo *	xmlParserFindNodeInfo	(xmlParserCtxtPtr ctx, 
    xmlNodePtr node)

    DEPRECATED: Don't use. Find the parser node info struct for a given node

    @@ -2488,7 +2590,7 @@

    xmlParserFindNodeInfoIndex ()

    -
    unsigned long	xmlParserFindNodeInfoIndex	(const xmlParserNodeInfoSeqPtr seq, 
    const xmlNodePtr node)
    +
    unsigned long	xmlParserFindNodeInfoIndex	(xmlParserNodeInfoSeqPtr seq, 
    xmlNodePtr node)

    DEPRECATED: Don't use. xmlParserFindNodeInfoIndex : Find the index that the info record for the given node is or should be at in a sorted sequence

    @@ -2586,7 +2688,7 @@

    xmlReadDoc ()

    xmlDocPtr	xmlReadDoc		(const xmlChar * cur, 
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree.

    +

    Convenience function to parse an XML document from a zero-terminated string. See xmlCtxtReadDoc for details.

    @@ -2596,11 +2698,11 @@

    - + - + @@ -2620,7 +2722,7 @@

    xmlReadFd ()

    xmlDocPtr	xmlReadFd		(int fd, 
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the reader is closed or reset.

    +

    Parse an XML from a file descriptor and build a tree. See xmlCtxtReadFd for details. NOTE that the file descriptor will not be closed when the context is freed or reset.

    URL:the base URL to use for the documentbase URL (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -2630,11 +2732,11 @@

    - + - + @@ -2654,7 +2756,7 @@

    xmlReadFile ()

    xmlDocPtr	xmlReadFile		(const char * filename, 
    const char * encoding,
    int options)
    -

    parse an XML file from the filesystem or the network.

    +

    Convenience function to parse an XML file from the filesystem, the network or a global user-define resource loader. See xmlCtxtReadFile for details.

    URL:the base URL to use for the documentbase URL (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -2664,7 +2766,7 @@

    - + @@ -2684,7 +2786,7 @@

    xmlReadIO ()

    xmlDocPtr	xmlReadIO		(xmlInputReadCallback ioread, 
    xmlInputCloseCallback ioclose,
    void * ioctx,
    const char * URL,
    const char * encoding,
    int options)
    -

    parse an XML document from I/O functions and source and build a tree.

    +

    Parse an XML document from I/O functions and context and build a tree. See xmlCtxtReadIO for details.

    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -2694,7 +2796,7 @@

    - + @@ -2702,11 +2804,11 @@

    - + - + @@ -2724,9 +2826,9 @@

    xmlReadMemory ()

    -
    xmlDocPtr	xmlReadMemory		(const char * buffer, 
    int size,
    const char * URL,
    const char * encoding,
    int options)
    +
    xmlDocPtr	xmlReadMemory		(const char * buffer, 
    int size,
    const char * url,
    const char * encoding,
    int options)
    -

    parse an XML in-memory document and build a tree.

    +

    Parse an XML in-memory document and build a tree. The input buffer must not contain a terminating null byte. See xmlCtxtReadMemory for details.

    ioclose:an I/O close functionan I/O close function (optional)
    ioctx:
    URL:the base URL to use for the documentbase URL (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -2739,12 +2841,12 @@

    - - + + - + diff --git a/doc/devhelp/libxml2-parserInternals.html b/doc/devhelp/libxml2-parserInternals.html index 38a46419b..13adbc876 100644 --- a/doc/devhelp/libxml2-parserInternals.html +++ b/doc/devhelp/libxml2-parserInternals.html @@ -65,6 +65,7 @@

    Synopsis

    xmlParserCtxtPtrxmlCreateFileParserCtxt (const char * filename); xmlParserCtxtPtrxmlCreateMemoryParserCtxt (const char * buffer,
    int size); xmlParserCtxtPtrxmlCreateURLParserCtxt (const char * filename,
    int options); +void xmlCtxtErrMemory (xmlParserCtxtPtr ctxt); int xmlCurrentChar (xmlParserCtxtPtr ctxt,
    int * len); xmlChar * xmlDecodeEntities (xmlParserCtxtPtr ctxt,
    int len,
    int what,
    xmlChar end,
    xmlChar end2,
    xmlChar end3); typedef void xmlEntityReferenceFunc (xmlEntityPtr ent,
    xmlNodePtr firstNode,
    xmlNodePtr lastNode); @@ -74,7 +75,7 @@

    Synopsis

    xmlChar * xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt); xmlChar * xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt); xmlChar * xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
    xmlChar ** prefix); -xmlParserInputPtrxmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
    xmlEntityPtr entity); +xmlParserInputPtrxmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
    xmlEntityPtr ent); xmlParserInputPtrxmlNewInputFromFile (xmlParserCtxtPtr ctxt,
    const char * filename); xmlParserInputPtrxmlNewInputStream (xmlParserCtxtPtr ctxt); xmlParserInputPtrxmlNewStringInputStream (xmlParserCtxtPtr ctxt,
    const xmlChar * buffer); @@ -133,11 +134,12 @@

    Synopsis

    xmlChar * xmlScanName (xmlParserCtxtPtr ctxt); void xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func); int xmlSkipBlankChars (xmlParserCtxtPtr ctxt); -xmlChar * xmlSplitQName (xmlParserCtxtPtr ctxt,
    const xmlChar * name,
    xmlChar ** prefix); +xmlChar * xmlSplitQName (xmlParserCtxtPtr ctxt,
    const xmlChar * name,
    xmlChar ** prefixOut); int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
    const xmlChar * cur,
    int * len); xmlChar * xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
    const xmlChar * str,
    int what,
    xmlChar end,
    xmlChar end2,
    xmlChar end3); xmlChar * xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt,
    const xmlChar * str,
    int len,
    int what,
    xmlChar end,
    xmlChar end2,
    xmlChar end3); int xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
    xmlCharEncoding enc); +int xmlSwitchEncodingName (xmlParserCtxtPtr ctxt,
    const char * encoding); int xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt,
    xmlParserInputPtr input,
    xmlCharEncodingHandlerPtr handler); int xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
    xmlCharEncodingHandlerPtr handler); @@ -547,7 +549,7 @@

    Variable xmlParserMaxDepth

    -
    unsigned int xmlParserMaxDepth;
    +
    const unsigned int xmlParserMaxDepth;
     

    arbitrary depth limit for the XML documents that we allow to process. This is not a limitation of the parser but a safety boundary feature. It can be disabled with the XML_PARSE_HUGE parser option.

    @@ -796,7 +798,7 @@

    xmlCreateEntityParserCtxt ()

    xmlParserCtxtPtr	xmlCreateEntityParserCtxt	(const xmlChar * URL, 
    const xmlChar * ID,
    const xmlChar * base)
    -

    Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

    +

    DEPRECATED: Use xmlNewInputURL. Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

    the size of the array
    URL:the base URL to use for the documenturl:base URL (optional)
    encoding:the document encoding, or NULLthe document encoding (optional)
    options:
    @@ -825,7 +827,7 @@

    xmlCreateFileParserCtxt ()

    xmlParserCtxtPtr	xmlCreateFileParserCtxt	(const char * filename)
    -

    Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

    +

    DEPRECATED: Use xmlNewParserCtxt and xmlCtxtReadFile. Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

    @@ -846,7 +848,7 @@

    xmlCreateMemoryParserCtxt ()

    xmlParserCtxtPtr	xmlCreateMemoryParserCtxt	(const char * buffer, 
    int size)
    -

    Create a parser context for an XML in-memory document.

    +

    Create a parser context for an XML in-memory document. The input buffer must not contain a terminating null byte.

    @@ -871,7 +873,7 @@

    xmlCreateURLParserCtxt ()

    xmlParserCtxtPtr	xmlCreateURLParserCtxt	(const char * filename, 
    int options)
    -

    Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses

    +

    DEPRECATED: Use xmlNewParserCtxt and xmlCtxtReadFile. Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses

    @@ -894,6 +896,21 @@


    +xmlCtxtErrMemory ()

    +
    void	xmlCtxtErrMemory		(xmlParserCtxtPtr ctxt)
    +
    +

    Handle an out-of-memory error. Available since 2.13.0.

    +

    ++ + + + +
    ctxt:an XML parser context
    +
    +
    +
    +

    xmlCurrentChar ()

    int	xmlCurrentChar			(xmlParserCtxtPtr ctxt, 
    int * len)
    @@ -1087,7 +1104,7 @@

    xmlNewEntityInputStream ()

    -
    xmlParserInputPtr	xmlNewEntityInputStream	(xmlParserCtxtPtr ctxt, 
    xmlEntityPtr entity)
    +
    xmlParserInputPtr	xmlNewEntityInputStream	(xmlParserCtxtPtr ctxt, 
    xmlEntityPtr ent)

    DEPRECATED: Internal function, do not use. Create a new input stream based on an xmlEntityPtr

    @@ -1098,7 +1115,7 @@

    - + @@ -1359,7 +1376,7 @@

    xmlParseContent ()

    void	xmlParseContent			(xmlParserCtxtPtr ctxt)
    -

    Parse a content sequence. Stops at EOF or '</'. [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*

    +

    Parse XML element content. This is useful if you're only interested in custom SAX callbacks. If you want a node list, use xmlParseInNodeContext.

    an XML parser context
    entity:ent: an Entity pointer
    @@ -1602,7 +1619,7 @@

    xmlParseEntityRef ()

    xmlEntityPtr	xmlParseEntityRef	(xmlParserCtxtPtr ctxt)
    -

    DEPRECATED: Internal function, don't use. Parse an entitiy reference. Always consumes '&'. [68] EntityRef ::= '&' Name ';' [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", the Name given in the entity reference must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot. The declaration of a parameter entity must precede any reference to it. Similarly, the declaration of a general entity must precede any reference to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'. [ WFC: Parsed Entity ] An entity reference must not contain the name of an unparsed entity

    +

    DEPRECATED: Internal function, don't use.

    @@ -2182,7 +2199,7 @@

    xmlPushInput ()

    int	xmlPushInput			(xmlParserCtxtPtr ctxt, 
    xmlParserInputPtr input)
    -

    xmlPushInput: switch to a new input stream which is stacked on top of the previous one(s).

    +

    Push an input stream onto the stack. This makes the parser use an input returned from advanced functions like xmlNewInputURL or xmlNewInputMemory.

    @@ -2243,7 +2260,7 @@

    xmlSkipBlankChars ()

    int	xmlSkipBlankChars		(xmlParserCtxtPtr ctxt)
    -

    DEPRECATED: Internal function, do not use. skip all blanks character found at that point in the input streams. It pops up finished entities in the process if allowable at that point.

    +

    DEPRECATED: Internal function, do not use. Skip whitespace in the input stream.

    @@ -2262,7 +2279,7 @@

    xmlSplitQName ()

    -
    xmlChar *	xmlSplitQName		(xmlParserCtxtPtr ctxt, 
    const xmlChar * name,
    xmlChar ** prefix)
    +
    xmlChar *	xmlSplitQName		(xmlParserCtxtPtr ctxt, 
    const xmlChar * name,
    xmlChar ** prefixOut)

    parse an UTF8 encoded XML qualified name string [NS 5] QName ::= (Prefix ':')? LocalPart [NS 6] Prefix ::= NCName [NS 7] LocalPart ::= NCName

    @@ -2277,7 +2294,7 @@

    - + @@ -2322,7 +2339,7 @@

    xmlStringDecodeEntities ()

    xmlChar *	xmlStringDecodeEntities	(xmlParserCtxtPtr ctxt, 
    const xmlChar * str,
    int what,
    xmlChar end,
    xmlChar end2,
    xmlChar end3)
    -

    DEPRECATED: Internal function, don't use. Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';'

    +

    DEPRECATED: Internal function, don't use.

    an XML parser context
    prefix:prefixOut: a xmlChar **
    @@ -2364,7 +2381,7 @@

    xmlStringLenDecodeEntities ()

    xmlChar *	xmlStringLenDecodeEntities	(xmlParserCtxtPtr ctxt, 
    const xmlChar * str,
    int len,
    int what,
    xmlChar end,
    xmlChar end2,
    xmlChar end3)
    -

    DEPRECATED: Internal function, don't use. Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';'

    +

    DEPRECATED: Internal function, don't use.

    @@ -2410,7 +2427,7 @@

    xmlSwitchEncoding ()

    int	xmlSwitchEncoding		(xmlParserCtxtPtr ctxt, 
    xmlCharEncoding enc)
    -

    Use encoding specified by enum to decode input data. This function can be used to enforce the encoding of chunks passed to xmlParseChunk.

    +

    Use encoding specified by enum to decode input data. This overrides the encoding found in the XML declaration. This function can also be used to override the encoding of chunks passed to xmlParseChunk.

    @@ -2432,6 +2449,31 @@


    +xmlSwitchEncodingName ()

    +
    int	xmlSwitchEncodingName		(xmlParserCtxtPtr ctxt, 
    const char * encoding)
    +
    +

    Use specified encoding to decode input data. This overrides the encoding found in the XML declaration. This function can also be used to override the encoding of chunks passed to xmlParseChunk. Available since 2.13.0.

    +

    ++ + + + + + + + + + + + + + +
    ctxt:the parser context
    encoding:the encoding name
    Returns:0 in case of success, -1 otherwise
    +
    +
    +
    +

    xmlSwitchInputEncoding ()

    int	xmlSwitchInputEncoding		(xmlParserCtxtPtr ctxt, 
    xmlParserInputPtr input,
    xmlCharEncodingHandlerPtr handler)
    @@ -2441,7 +2483,7 @@

    ctxt: -the parser context +the parser context, only for error reporting input: diff --git a/doc/devhelp/libxml2-pattern.html b/doc/devhelp/libxml2-pattern.html index 72992a6cb..332ca7b8f 100644 --- a/doc/devhelp/libxml2-pattern.html +++ b/doc/devhelp/libxml2-pattern.html @@ -30,6 +30,7 @@

    Synopsis

    void xmlFreePattern (xmlPatternPtr comp); void xmlFreePatternList (xmlPatternPtr comp); void xmlFreeStreamCtxt (xmlStreamCtxtPtr stream); +int xmlPatternCompileSafe (const xmlChar * pattern,
    xmlDict * dict,
    int flags,
    const xmlChar ** namespaces,
    xmlPatternPtr * patternOut); int xmlPatternFromRoot (xmlPatternPtr comp); xmlStreamCtxtPtr xmlPatternGetStreamCtxt (xmlPatternPtr comp); int xmlPatternMatch (xmlPatternPtr comp,
    xmlNodePtr node); @@ -144,6 +145,44 @@


    +xmlPatternCompileSafe ()

    +
    int	xmlPatternCompileSafe		(const xmlChar * pattern, 
    xmlDict * dict,
    int flags,
    const xmlChar ** namespaces,
    xmlPatternPtr * patternOut)
    +
    +

    Compile a pattern. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + + + + + + + + + +
    pattern:the pattern to compile
    dict:an optional dictionary for interned strings
    flags:compilation flags, see xmlPatternFlags +
    namespaces:the prefix definitions, array of [URI, prefix] or NULL
    patternOut:output pattern
    Returns:0 on success, 1 on error, -1 if a memory allocation failed.
    +
    +
    +
    +

    xmlPatternFromRoot ()

    int	xmlPatternFromRoot		(xmlPatternPtr comp)
    diff --git a/doc/devhelp/libxml2-relaxng.html b/doc/devhelp/libxml2-relaxng.html index 72d1b8be0..7a01a4d23 100644 --- a/doc/devhelp/libxml2-relaxng.html +++ b/doc/devhelp/libxml2-relaxng.html @@ -517,7 +517,7 @@

    xmlRelaxNGSetParserErrors ()

    void	xmlRelaxNGSetParserErrors	(xmlRelaxNGParserCtxtPtr ctxt, 
    xmlRelaxNGValidityErrorFunc err,
    xmlRelaxNGValidityWarningFunc warn,
    void * ctx)
    -

    Set the callback functions used to handle errors for a validation context

    +

    DEPRECATED: Use xmlRelaxNGSetParserStructuredErrors. Set the callback functions used to handle errors for a validation context

    @@ -571,7 +571,7 @@

    xmlRelaxNGSetValidErrors ()

    void	xmlRelaxNGSetValidErrors	(xmlRelaxNGValidCtxtPtr ctxt, 
    xmlRelaxNGValidityErrorFunc err,
    xmlRelaxNGValidityWarningFunc warn,
    void * ctx)
    -

    Set the error and warning callback information

    +

    DEPRECATED: Use xmlRelaxNGSetValidStructuredErrors. Set the error and warning callback information

    diff --git a/doc/devhelp/libxml2-tree.html b/doc/devhelp/libxml2-tree.html index 61d6aa78e..814163a4b 100644 --- a/doc/devhelp/libxml2-tree.html +++ b/doc/devhelp/libxml2-tree.html @@ -86,9 +86,9 @@

    Synopsis

    typedef xmlSAXLocator * xmlSAXLocatorPtr; xmlNodePtrxmlAddChild (xmlNodePtr parent,
    xmlNodePtr cur); xmlNodePtrxmlAddChildList (xmlNodePtr parent,
    xmlNodePtr cur); -xmlNodePtrxmlAddNextSibling (xmlNodePtr cur,
    xmlNodePtr elem); -xmlNodePtrxmlAddPrevSibling (xmlNodePtr cur,
    xmlNodePtr elem); -xmlNodePtrxmlAddSibling (xmlNodePtr cur,
    xmlNodePtr elem); +xmlNodePtrxmlAddNextSibling (xmlNodePtr prev,
    xmlNodePtr cur); +xmlNodePtrxmlAddPrevSibling (xmlNodePtr next,
    xmlNodePtr cur); +xmlNodePtrxmlAddSibling (xmlNodePtr node,
    xmlNodePtr cur); void xmlAttrSerializeTxtContent (xmlBufferPtr buf,
    xmlDocPtr doc,
    xmlAttrPtr attr,
    const xmlChar * string); xmlChar * xmlBufContent (const xmlBuf * buf); xmlChar * xmlBufEnd (xmlBufPtr buf); @@ -165,6 +165,7 @@

    Synopsis

    xmlChar * xmlGetNoNsProp (const xmlNode * node,
    const xmlChar * name); xmlChar * xmlGetNodePath (const xmlNode * node); xmlNsPtr * xmlGetNsList (const xmlDoc * doc,
    const xmlNode * node); +int xmlGetNsListSafe (const xmlDoc * doc,
    const xmlNode * node,
    xmlNsPtr ** out); xmlChar * xmlGetNsProp (const xmlNode * node,
    const xmlChar * name,
    const xmlChar * nameSpace); xmlChar * xmlGetProp (const xmlNode * node,
    const xmlChar * name); xmlAttrPtrxmlHasNsProp (const xmlNode * node,
    const xmlChar * name,
    const xmlChar * nameSpace); @@ -200,24 +201,26 @@

    Synopsis

    xmlNodePtrxmlNewTextChild (xmlNodePtr parent,
    xmlNsPtr ns,
    const xmlChar * name,
    const xmlChar * content); xmlNodePtrxmlNewTextLen (const xmlChar * content,
    int len); xmlNodePtrxmlNextElementSibling (xmlNodePtr node); -void xmlNodeAddContent (xmlNodePtr cur,
    const xmlChar * content); -void xmlNodeAddContentLen (xmlNodePtr cur,
    const xmlChar * content,
    int len); +int xmlNodeAddContent (xmlNodePtr cur,
    const xmlChar * content); +int xmlNodeAddContentLen (xmlNodePtr cur,
    const xmlChar * content,
    int len); int xmlNodeBufGetContent (xmlBufferPtr buffer,
    const xmlNode * cur); int xmlNodeDump (xmlBufferPtr buf,
    xmlDocPtr doc,
    xmlNodePtr cur,
    int level,
    int format); void xmlNodeDumpOutput (xmlOutputBufferPtr buf,
    xmlDocPtr doc,
    xmlNodePtr cur,
    int level,
    int format,
    const char * encoding); +int xmlNodeGetAttrValue (const xmlNode * node,
    const xmlChar * name,
    const xmlChar * nsUri,
    xmlChar ** out); xmlChar * xmlNodeGetBase (const xmlDoc * doc,
    const xmlNode * cur); +int xmlNodeGetBaseSafe (const xmlDoc * doc,
    const xmlNode * cur,
    xmlChar ** baseOut); xmlChar * xmlNodeGetContent (const xmlNode * cur); xmlChar * xmlNodeGetLang (const xmlNode * cur); int xmlNodeGetSpacePreserve (const xmlNode * cur); int xmlNodeIsText (const xmlNode * node); xmlChar * xmlNodeListGetRawString (const xmlDoc * doc,
    const xmlNode * list,
    int inLine); xmlChar * xmlNodeListGetString (xmlDocPtr doc,
    const xmlNode * list,
    int inLine); -void xmlNodeSetBase (xmlNodePtr cur,
    const xmlChar * uri); -void xmlNodeSetContent (xmlNodePtr cur,
    const xmlChar * content); -void xmlNodeSetContentLen (xmlNodePtr cur,
    const xmlChar * content,
    int len); -void xmlNodeSetLang (xmlNodePtr cur,
    const xmlChar * lang); +int xmlNodeSetBase (xmlNodePtr cur,
    const xmlChar * uri); +int xmlNodeSetContent (xmlNodePtr cur,
    const xmlChar * content); +int xmlNodeSetContentLen (xmlNodePtr cur,
    const xmlChar * content,
    int len); +int xmlNodeSetLang (xmlNodePtr cur,
    const xmlChar * lang); void xmlNodeSetName (xmlNodePtr cur,
    const xmlChar * name); -void xmlNodeSetSpacePreserve (xmlNodePtr cur,
    int val); +int xmlNodeSetSpacePreserve (xmlNodePtr cur,
    int val); xmlNodePtrxmlPreviousElementSibling (xmlNodePtr node); int xmlReconciliateNs (xmlDocPtr doc,
    xmlNodePtr tree); xmlRegisterNodeFuncxmlRegisterNodeDefault (xmlRegisterNodeFunc func); @@ -235,11 +238,11 @@

    Synopsis

    void xmlSetBufferAllocationScheme (xmlBufferAllocationScheme scheme); void xmlSetCompressMode (int mode); void xmlSetDocCompressMode (xmlDocPtr doc,
    int mode); -void xmlSetListDoc (xmlNodePtr list,
    xmlDocPtr doc); +int xmlSetListDoc (xmlNodePtr list,
    xmlDocPtr doc); void xmlSetNs (xmlNodePtr node,
    xmlNsPtr ns); xmlAttrPtrxmlSetNsProp (xmlNodePtr node,
    xmlNsPtr ns,
    const xmlChar * name,
    const xmlChar * value); xmlAttrPtrxmlSetProp (xmlNodePtr node,
    const xmlChar * name,
    const xmlChar * value); -void xmlSetTreeDoc (xmlNodePtr tree,
    xmlDocPtr doc); +int xmlSetTreeDoc (xmlNodePtr tree,
    xmlDocPtr doc); xmlChar * xmlSplitQName2 (const xmlChar * name,
    xmlChar ** prefix); const xmlChar * xmlSplitQName3 (const xmlChar * name,
    int * len); xmlNodePtrxmlStringGetNodeList (const xmlDoc * doc,
    const xmlChar * value); @@ -351,6 +354,7 @@

    xmlNs * ns : pointer to the associated namespace xmlAttributeType atype : the attribute type if validating void * psvi : for type/PSVI information + struct _xmlID * id : the ID struct } xmlAttr;

    @@ -687,13 +691,13 @@

    XML_TEXT_NODE = 3 XML_CDATA_SECTION_NODE = 4 XML_ENTITY_REF_NODE = 5 - XML_ENTITY_NODE = 6 + XML_ENTITY_NODE = 6 /* unused */ XML_PI_NODE = 7 XML_COMMENT_NODE = 8 XML_DOCUMENT_NODE = 9 - XML_DOCUMENT_TYPE_NODE = 10 + XML_DOCUMENT_TYPE_NODE = 10 /* unused */ XML_DOCUMENT_FRAG_NODE = 11 - XML_NOTATION_NODE = 12 + XML_NOTATION_NODE = 12 /* unused */ XML_HTML_DOCUMENT_NODE = 13 XML_DTD_NODE = 14 XML_ELEMENT_DECL = 15 @@ -742,7 +746,7 @@

    const xmlChar * SystemID : URI for a SYSTEM or PUBLIC Entity struct _xmlEntity * nexte : unused const xmlChar * URI : the full URI as computed - int owner : does the entity own the childrens + int owner : unused int flags : various flags unsigned long expandedSize : expanded size } xmlEntity; @@ -935,13 +939,13 @@

    int errNo : error code int hasExternalSubset : reference and external subset int hasPErefs : the internal subset has PE refs - int external : are we parsing an external entity + int external : unused int valid : is the document valid int validate : shall we try to validate ? xmlValidCtxt vctxt : The validity context - xmlParserInputState instate : current type of input - int token : next char look-ahead - char * directory : the data directory Node name stack + xmlParserInputState instate : push parser state + int token : unused + char * directory : unused Node name stack const xmlChar * name : Current parsed Node int nameNr : Depth of the parsing stack int nameMax : Max depth of the parsing stack @@ -959,7 +963,7 @@

    int spaceMax : Max depth of the parsing stack int * spaceTab : array of space infos int depth : to prevent entity substitution loops - xmlParserInputPtr entity : used to check entities boundaries + xmlParserInputPtr entity : unused int charset : unused int nodelen : Those two fields are there to int nodemem : Speed up large node parsing @@ -969,7 +973,7 @@

    int linenumbers : set line number in element content void * catalogs : document's own catalog int recovery : run in recovery mode - int progressive : is this a progressive parsing + int progressive : unused xmlDictPtr dict : dictionary for the parser const xmlChar * * atts : array for the attributes callbacks int maxatts : the size of the array @@ -995,7 +999,7 @@

    xmlError lastError xmlParserMode parseMode : the parser mode unsigned long nbentities : unused - unsigned long sizeentities : size of parsed entities for use by HTML non-recursive parser + unsigned long sizeentities : size of external entities for use by HTML non-recursive parser xmlParserNodeInfo * nodeInfo : Current NodeInfo int nodeInfoNr : Depth of the parsing stack int nodeInfoMax : Max depth of the parsing stack @@ -1009,6 +1013,8 @@

    xmlParserNsData * nsdb : namespace database unsigned attrHashMax : allocated size xmlAttrHashBucket * attrHash : atttribute hash table + xmlStructuredErrorFunc errorHandler + void * errorCtxt } xmlParserCtxt;

    @@ -1028,11 +1034,11 @@

    struct _xmlParserInput {
         xmlParserInputBufferPtr	buf	: UTF-8 encoded buffer
         const char *	filename	: The file analyzed, if any
    -    const char *	directory	: the directory/base of the file
    +    const char *	directory	: unused
         const xmlChar *	base	: Base of the array to parse
         const xmlChar *	cur	: Current char being parsed
         const xmlChar *	end	: end of the array to parse
    -    int	length	: length if known
    +    int	length	: unused
         int	line	: Current line
         int	col	: Current column
         unsigned long	consumed	: How many xmlChars already consumed
    @@ -1041,7 +1047,7 @@ 

    const xmlChar * version : the version string for entity int flags : Flags int id : an unique identifier for the entity - unsigned long parentConsumed : consumed bytes from parents + unsigned long parentConsumed : unused xmlEntityPtr entity : entity, if any } xmlParserInput;

    @@ -1121,7 +1127,7 @@

    unparsedEntityDeclSAXFunc unparsedEntityDecl setDocumentLocatorSAXFunc setDocumentLocator startDocumentSAXFunc startDocument - endDocumentSAXFunc endDocument + endDocumentSAXFunc endDocument : * `startElement` and `endElement` are only used by the legacy SAX1 * i startElementSAXFunc startElement endElementSAXFunc endElement referenceSAXFunc reference @@ -1134,8 +1140,8 @@

    fatalErrorSAXFunc fatalError : unused error() get all the errors getParameterEntitySAXFunc getParameterEntity cdataBlockSAXFunc cdataBlock - externalSubsetSAXFunc externalSubset - unsigned int initialized : The following fields are extensions available only on version 2 + externalSubsetSAXFunc externalSubset : * `initialized` should always be set to XML_SAX2_MAGIC to enable the * + unsigned int initialized : * The following members are only used by the SAX2 interface. * void * _private startElementNsSAX2Func startElementNs endElementNsSAX2Func endElementNs @@ -1242,7 +1248,7 @@

    xmlAddChild ()

    xmlNodePtr	xmlAddChild		(xmlNodePtr parent, 
    xmlNodePtr cur)
    -

    Add a new node to @parent, at the end of the child (or property) list merging adjacent TEXT nodes (in which case @cur is freed) If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed. All tree manipulation functions can safely move nodes within a document. But when moving nodes from one document to another, references to namespaces in element or attribute nodes are NOT fixed. In this case, you MUST call xmlReconciliateNs after the move operation to avoid memory errors.

    +

    Unlink @cur and append it to the children of @parent. If @cur is a text node, it may be merged with an adjacent text node and freed. In this case the text node containing the merged content is returned. If @cur is an attribute node, it is appended to the attributes of @parent. If the attribute list contains an attribute with a name matching @elem, the old attribute is destroyed. General notes: Move operations like xmlAddChild can cause element or attribute nodes to reference namespaces that aren't declared in one of their ancestors. This can lead to use-after-free errors if the elements containing the declarations are freed later, especially when moving nodes from one document to another. You should consider calling xmlReconciliateNs after a move operation to normalize namespaces. Another option is to call xmlDOMWrapAdoptNode with the target parent before moving a node. For the most part, move operations don't check whether the resulting tree structure is valid. Users must make sure that parent nodes only receive children of valid types. Inserted child nodes must never be an ancestor of the parent node to avoid cycles in the tree structure. In general, only document, document fragments, elements and attributes should be used as parent nodes. When moving a node between documents and a memory allocation fails, the node's content will be corrupted and it will be unlinked. In this case, the node must be freed manually. Moving DTDs between documents isn't supported.

    @@ -1256,7 +1262,7 @@

    - +
    Returns:the child or NULL in case of error.@elem or a sibling if @elem was merged. Returns NULL if arguments are invalid or a memory allocation failed.
    @@ -1267,7 +1273,7 @@

    xmlAddChildList ()

    xmlNodePtr	xmlAddChildList		(xmlNodePtr parent, 
    xmlNodePtr cur)
    -

    Add a list of node at the end of the child list of the parent merging adjacent TEXT nodes (@cur may be freed) See the note regarding namespaces in xmlAddChild.

    +

    Append a node list to another node. See xmlAddChild.

    @@ -1290,23 +1296,23 @@

    xmlAddNextSibling ()

    -
    xmlNodePtr	xmlAddNextSibling	(xmlNodePtr cur, 
    xmlNodePtr elem)
    +
    xmlNodePtr	xmlAddNextSibling	(xmlNodePtr prev, 
    xmlNodePtr cur)
    -

    Add a new node @elem as the next sibling of @cur If the new node was already inserted in a document it is first unlinked from its existing context. As a result of text merging @elem may be freed. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed. See the note regarding namespaces in xmlAddChild.

    +

    Unlinks @cur and inserts it as next sibling after @prev. Unlike xmlAddChild this function does not merge text nodes. If @cur is an attribute node, it is inserted after attribute @prev. If the attribute list contains an attribute with a name matching @cur, the old attribute is destroyed. See the notes in xmlAddChild.

    - - + + - + - +
    cur:the child nodeprev:the target node
    elem:cur: the new node
    Returns:the new node or NULL in case of error.@cur or a sibling if @cur was merged. Returns NULL if arguments are invalid or a memory allocation failed.
    @@ -1315,23 +1321,23 @@

    xmlAddPrevSibling ()

    -
    xmlNodePtr	xmlAddPrevSibling	(xmlNodePtr cur, 
    xmlNodePtr elem)
    +
    xmlNodePtr	xmlAddPrevSibling	(xmlNodePtr next, 
    xmlNodePtr cur)
    -

    Add a new node @elem as the previous sibling of @cur merging adjacent TEXT nodes (@elem may be freed) If the new node was already inserted in a document it is first unlinked from its existing context. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed. See the note regarding namespaces in xmlAddChild.

    +

    Unlinks @cur and inserts it as previous sibling before @next. Unlike xmlAddChild this function does not merge text nodes. If @cur is an attribute node, it is inserted before attribute @next. If the attribute list contains an attribute with a name matching @cur, the old attribute is destroyed. See the notes in xmlAddChild.

    - - + + - + - +
    cur:the child nodenext:the target node
    elem:cur: the new node
    Returns:the new node or NULL in case of error.@cur or a sibling if @cur was merged. Returns NULL if arguments are invalid or a memory allocation failed.
    @@ -1340,23 +1346,23 @@

    xmlAddSibling ()

    -
    xmlNodePtr	xmlAddSibling		(xmlNodePtr cur, 
    xmlNodePtr elem)
    +
    xmlNodePtr	xmlAddSibling		(xmlNodePtr node, 
    xmlNodePtr cur)
    -

    Add a new element @elem to the list of siblings of @cur merging adjacent TEXT nodes (@elem may be freed) If the new element was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in xmlAddChild.

    +

    Unlinks @cur and inserts it as last sibling of @node. If @cur is a text node, it may be merged with an adjacent text node and freed. In this case the text node containing the merged content is returned. If @cur is an attribute node, it is appended to the attribute list containing @node. If the attribute list contains an attribute with a name matching @cur, the old attribute is destroyed. See the notes in xmlAddChild.

    - - + + - + - +
    cur:the child nodenode:the target node
    elem:cur: the new node
    Returns:the new element or NULL in case of error.@cur or a sibling if @cur was merged. Returns NULL if arguments are invalid or a memory allocation failed.
    @@ -2026,7 +2032,7 @@

    xmlChildElementCount ()

    unsigned long	xmlChildElementCount	(xmlNodePtr parent)
    -

    Finds the current number of child nodes of that element which are element nodes. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references.

    +

    Count the number of child nodes which are elements. Note that entity references are not expanded.

    @@ -2036,7 +2042,7 @@

    - +
    Returns:the count of element child or 0 if not availablethe number of element children or 0 if arguments are invalid.
    @@ -2047,7 +2053,7 @@

    xmlCopyDoc ()

    xmlDocPtr	xmlCopyDoc		(xmlDocPtr doc, 
    int recursive)
    -

    Do a copy of the document info. If recursive, the content tree will be copied too as well as DTD, namespaces and entities.

    +

    Copy a document. If recursive, the content tree will be copied too as well as DTD, namespaces and entities.

    @@ -2061,7 +2067,7 @@

    - +
    Returns:a new #xmlDocPtr, or NULL in case of error.the copied document or NULL if a memory allocation failed.
    @@ -2072,17 +2078,17 @@

    xmlCopyDtd ()

    xmlDtdPtr	xmlCopyDtd		(xmlDtdPtr dtd)
    -

    Do a copy of the dtd.

    +

    Copy a DTD.

    - + - +
    dtd:the dtdthe DTD
    Returns:a new #xmlDtdPtr, or NULL in case of error.the copied DTD or NULL if a memory allocation failed.
    @@ -2093,7 +2099,7 @@

    xmlCopyNamespace ()

    xmlNsPtr	xmlCopyNamespace	(xmlNsPtr cur)
    -

    Do a copy of the namespace.

    +

    Copy a namespace.

    @@ -2103,7 +2109,7 @@

    - +
    Returns:a new #xmlNsPtr, or NULL in case of error.the copied namespace or NULL if a memory allocation failed.
    @@ -2114,7 +2120,7 @@

    xmlCopyNamespaceList ()

    xmlNsPtr	xmlCopyNamespaceList	(xmlNsPtr cur)
    -

    Do a copy of an namespace list.

    +

    Copy a namespace list.

    @@ -2124,7 +2130,7 @@

    - +
    Returns:a new #xmlNsPtr, or NULL in case of error.the head of the copied list or NULL if a memory allocation failed.
    @@ -2135,7 +2141,7 @@

    xmlCopyNode ()

    xmlNodePtr	xmlCopyNode		(xmlNodePtr node, 
    int extended)
    -

    Do a copy of the node.

    +

    Copy a node. Use of this function is DISCOURAGED in favor of xmlDocCopyNode.

    @@ -2149,7 +2155,7 @@

    - +
    Returns:a new #xmlNodePtr, or NULL in case of error.the copied node or NULL if a memory allocation failed.
    @@ -2160,7 +2166,7 @@

    xmlCopyNodeList ()

    xmlNodePtr	xmlCopyNodeList		(xmlNodePtr node)
    -

    Do a recursive copy of the node list. Use xmlDocCopyNodeList() if possible to ensure string interning.

    +

    Copy a node list and all children. Use of this function is DISCOURAGED in favor of xmlDocCopyNodeList.

    @@ -2170,7 +2176,7 @@

    - +
    Returns:a new #xmlNodePtr, or NULL in case of error.the head of the copied list or NULL if a memory allocation failed.
    @@ -2181,7 +2187,7 @@

    xmlCopyProp ()

    xmlAttrPtr	xmlCopyProp		(xmlNodePtr target, 
    xmlAttrPtr cur)
    -

    Do a copy of the attribute.

    +

    Create a copy of the attribute. This function sets the parent pointer of the copy to @target but doesn't set the attribute on the target element. Users should consider to set the attribute by calling xmlAddChild afterwards or reset the parent pointer to NULL.

    @@ -2196,7 +2202,7 @@

    - +
    Returns:a new #xmlAttrPtr, or NULL in case of error.the copied attribute or NULL if a memory allocation failed.
    @@ -2207,7 +2213,7 @@

    xmlCopyPropList ()

    xmlAttrPtr	xmlCopyPropList		(xmlNodePtr target, 
    xmlAttrPtr cur)
    -

    Do a copy of an attribute list.

    +

    Create a copy of an attribute list. This function sets the parent pointers of the copied attributes to @target but doesn't set the attributes on the target element.

    @@ -2222,7 +2228,7 @@

    - +
    Returns:a new #xmlAttrPtr, or NULL in case of error.the head of the copied list or NULL if a memory allocation failed.
    @@ -2233,29 +2239,29 @@

    xmlCreateIntSubset ()

    xmlDtdPtr	xmlCreateIntSubset	(xmlDocPtr doc, 
    const xmlChar * name,
    const xmlChar * ExternalID,
    const xmlChar * SystemID)
    -

    Create the internal subset of a document

    +

    Create a DTD node. If a document is provided and it already has an internal subset, the existing DTD object is returned without creating a new object. If the document has no internal subset, it will be set to the created DTD.

    - + - + - + - + - +
    doc:the document pointerthe document pointer (optional)
    name:the DTD namethe DTD name (optional)
    ExternalID:the external (PUBLIC) IDthe external (PUBLIC) ID (optional)
    SystemID:the system IDthe system ID (optional)
    Returns:a pointer to the new DTD structurea pointer to the new or existing DTD object or NULL if arguments are invalid or a memory allocation failed.
    @@ -2448,7 +2454,7 @@

    xmlDeregisterNodeDefault ()

    xmlDeregisterNodeFunc	xmlDeregisterNodeDefault	(xmlDeregisterNodeFunc func)
    -

    Registers a callback for node destruction

    +

    DEPRECATED: don't use Registers a callback for node destruction

    @@ -2469,7 +2475,7 @@

    xmlDocCopyNode ()

    xmlNodePtr	xmlDocCopyNode		(xmlNodePtr node, 
    xmlDocPtr doc,
    int extended)
    -

    Do a copy of the node to a given document.

    +

    Copy a node into another document.

    @@ -2487,7 +2493,7 @@

    - +
    Returns:a new #xmlNodePtr, or NULL in case of error.the copied node or NULL if a memory allocation failed.
    @@ -2498,7 +2504,7 @@

    xmlDocCopyNodeList ()

    xmlNodePtr	xmlDocCopyNodeList	(xmlDocPtr doc, 
    xmlNodePtr node)
    -

    Do a recursive copy of the node list.

    +

    Copy a node list and all children into a new document.

    @@ -2512,7 +2518,7 @@

    - +
    Returns:a new #xmlNodePtr, or NULL in case of error.the head of the copied list or NULL if a memory allocation failed.
    @@ -2703,7 +2709,7 @@

    Returns: -the #xmlNodePtr for the root or NULL +the root element or NULL if no element was found.

    @@ -2714,7 +2720,7 @@

    xmlDocSetRootElement ()

    xmlNodePtr	xmlDocSetRootElement	(xmlDocPtr doc, 
    xmlNodePtr root)
    -

    Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...).

    +

    Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...). @root must be an element node. It is unlinked before insertion.

    @@ -2728,7 +2734,7 @@

    - +
    Returns:the old root element if any was found, NULL if root was NULLthe unlinked old root element or NULL if the document didn't have a root element or a memory allocation failed.
    @@ -2764,7 +2770,7 @@

    xmlFirstElementChild ()

    xmlNodePtr	xmlFirstElementChild	(xmlNodePtr parent)
    -

    Finds the first child node of that element which is a Element node Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references.

    +

    Find the first child node which is an element. Note that entity references are not expanded.

    @@ -2774,7 +2780,7 @@

    - +
    Returns:the first element child or NULL if not availablethe first element or NULL if parent has no children.
    @@ -2785,7 +2791,7 @@

    xmlFreeDoc ()

    void	xmlFreeDoc			(xmlDocPtr cur)
    -

    Free up all the structures used by a document, tree included.

    +

    Free a document including all children and associated DTDs.

    @@ -2815,7 +2821,7 @@

    xmlFreeNode ()

    void	xmlFreeNode			(xmlNodePtr cur)
    -

    Free a node, this is a recursive behaviour, all the children are freed too. This doesn't unlink the child from the list, use xmlUnlinkNode() first.

    +

    Free a node including all the children. This doesn't unlink the node from the tree. Call xmlUnlinkNode first unless @cur is a root node.

    @@ -2830,7 +2836,7 @@

    xmlFreeNodeList ()

    void	xmlFreeNodeList			(xmlNodePtr cur)
    -

    Free a node and all its siblings, this is a recursive behaviour, all the children are freed too.

    +

    Free a node list including all children.

    @@ -2845,7 +2851,7 @@

    xmlFreeNs ()

    void	xmlFreeNs			(xmlNsPtr cur)
    -

    Free up the structures associated to a namespace

    +

    Free an xmlNs object.

    @@ -2860,7 +2866,7 @@

    xmlFreeNsList ()

    void	xmlFreeNsList			(xmlNsPtr cur)
    -

    Free up all the structures associated to the chained namespaces.

    +

    Free a list of xmlNs objects.

    @@ -2875,7 +2881,7 @@

    xmlFreeProp ()

    void	xmlFreeProp			(xmlAttrPtr cur)
    -

    Free one attribute, all the content is freed too

    +

    Free an attribute including all children.

    @@ -2891,12 +2897,12 @@

    xmlFreePropList ()

    void	xmlFreePropList			(xmlAttrPtr cur)
    -

    Free a property and all its siblings, all the children are freed too.

    +

    Free an attribute list including all children.

    - +
    cur:the first property in the listthe first attribute in the list
    @@ -2921,7 +2927,7 @@

    xmlGetCompressMode ()

    int	xmlGetCompressMode		(void)
    -

    get the default compression mode used, ZLIB based.

    +

    DEPRECATED: Use xmlGetDocCompressMode get the default compression mode used, ZLIB based.

    @@ -2957,7 +2963,7 @@

    xmlGetIntSubset ()

    xmlDtdPtr	xmlGetIntSubset		(const xmlDoc * doc)
    -

    Get the internal subset of a document

    +

    Get the internal subset of a document.

    @@ -2967,7 +2973,7 @@

    - +
    Returns:a pointer to the DTD structure or NULL if not founda pointer to the DTD object or NULL if not found.
    @@ -2978,7 +2984,7 @@

    xmlGetLastChild ()

    xmlNodePtr	xmlGetLastChild		(const xmlNode * parent)
    -

    Search the last child of a node.

    +

    Find the last child of a node.

    @@ -2988,7 +2994,7 @@

    - +
    Returns:the last child or NULL if none.the last child or NULL if parent has no children.
    @@ -3020,7 +3026,7 @@

    xmlGetNoNsProp ()

    xmlChar *	xmlGetNoNsProp		(const xmlNode * node, 
    const xmlChar * name)
    -

    Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. This function is similar to xmlGetProp except it will accept only an attribute in no namespace.

    +

    Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. This function is similar to xmlGetProp except it will accept only an attribute in no namespace. NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue.

    @@ -3034,7 +3040,7 @@

    - +
    Returns:the attribute value or NULL if not found. It's up to the caller to free the memory with xmlFree().the attribute value or NULL if not found or a memory allocation failed. It's up to the caller to free the memory with xmlFree().
    @@ -3066,7 +3072,32 @@

    xmlGetNsList ()

    xmlNsPtr *	xmlGetNsList		(const xmlDoc * doc, 
    const xmlNode * node)
    -

    Search all the namespace applying to a given element.

    +

    Find all in-scope namespaces of a node. Use xmlGetNsListSafe for better error reporting.

    +
    ++ + + + + + + + + + + + + + +
    doc:the document
    node:the current node
    Returns:a NULL terminated array of namespace pointers that must be freed by the caller or NULL if no namespaces were found or a memory allocation failed.
    +
    +
    +
    +

    +xmlGetNsListSafe ()

    +
    int	xmlGetNsListSafe		(const xmlDoc * doc, 
    const xmlNode * node,
    xmlNsPtr ** out)
    +
    +

    Find all in-scope namespaces of a node. @out returns a NULL terminated array of namespace pointers that must be freed by the caller. Available since 2.13.0.

    @@ -3079,8 +3110,12 @@

    + + + + - +
    the current node
    out:the returned namespace array
    Returns:an NULL terminated array of all the #xmlNsPtr found that need to be freed by the caller or NULL if no namespace if defined0 on success, 1 if no namespaces were found, -1 if a memory allocation failed.
    @@ -3091,7 +3126,7 @@

    xmlGetNsProp ()

    xmlChar *	xmlGetNsProp		(const xmlNode * node, 
    const xmlChar * name,
    const xmlChar * nameSpace)
    -

    Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off.

    +

    Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue.

    @@ -3109,7 +3144,7 @@

    - +
    Returns:the attribute value or NULL if not found. It's up to the caller to free the memory with xmlFree().the attribute value or NULL if not found or a memory allocation failed. It's up to the caller to free the memory with xmlFree().
    @@ -3120,7 +3155,7 @@

    xmlGetProp ()

    xmlChar *	xmlGetProp		(const xmlNode * node, 
    const xmlChar * name)
    -

    Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. NOTE: this function acts independently of namespaces associated to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() for namespace aware processing.

    +

    Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. NOTE: This function acts independently of namespaces associated to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() for namespace aware processing. NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue.

    @@ -3134,7 +3169,7 @@

    - +
    Returns:the attribute value or NULL if not found. It's up to the caller to free the memory with xmlFree().the attribute value or NULL if not found or a memory allocation failed. It's up to the caller to free the memory with xmlFree().
    @@ -3145,7 +3180,7 @@

    xmlHasNsProp ()

    xmlAttrPtr	xmlHasNsProp		(const xmlNode * node, 
    const xmlChar * name,
    const xmlChar * nameSpace)
    -

    Search for an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. Note that a namespace of NULL indicates to use the default namespace.

    +

    Search for an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. Note that a namespace of NULL indicates to use the default namespace.

    @@ -3163,7 +3198,7 @@

    - +
    Returns:the attribute or the attribute declaration or NULL if neither was found.the attribute or the attribute declaration or NULL if neither was found. Also returns NULL if a memory allocation failed making this function unreliable.
    @@ -3174,7 +3209,7 @@

    xmlHasProp ()

    xmlAttrPtr	xmlHasProp		(const xmlNode * node, 
    const xmlChar * name)
    -

    Search an attribute associated to a node This function also looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off.

    +

    Search an attribute associated to a node This function also looks in DTD attribute declaration for #FIXED or default declaration values.

    @@ -3188,7 +3223,7 @@

    - +
    Returns:the attribute or the attribute declaration or NULL if neither was found.the attribute or the attribute declaration or NULL if neither was found. Also returns NULL if a memory allocation failed making this function unreliable.
    @@ -3245,7 +3280,7 @@

    xmlLastElementChild ()

    xmlNodePtr	xmlLastElementChild	(xmlNodePtr parent)
    -

    Finds the last child node of that element which is a Element node Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references.

    +

    Find the last child node which is an element. Note that entity references are not expanded.

    @@ -3255,7 +3290,7 @@

    - +
    Returns:the last element child or NULL if not availablethe last element or NULL if parent has no children.
    @@ -3266,25 +3301,25 @@

    xmlNewCDataBlock ()

    xmlNodePtr	xmlNewCDataBlock	(xmlDocPtr doc, 
    const xmlChar * content,
    int len)
    -

    Creation of a new node containing a CDATA block.

    +

    Create a CDATA section node.

    - + - + - + - +
    doc:the documentthe target document (optional)
    content:the CDATA block content contentraw text content (optional)
    len:the length of the blocksize of text content
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -3295,21 +3330,21 @@

    xmlNewCharRef ()

    xmlNodePtr	xmlNewCharRef		(xmlDocPtr doc, 
    const xmlChar * name)
    -

    Creation of a new character reference node.

    +

    This function is MISNAMED. It doesn't create a character reference but an entity reference. Create an empty entity reference node. This function doesn't attempt to look up the entity in @doc. Entity names like '&entity;' are handled as well.

    - + - + - +
    doc:the documentthe target document (optional)
    name:the char ref string, starting with # or "&# ... ;"the entity name
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3320,7 +3355,7 @@

    xmlNewChild ()

    xmlNodePtr	xmlNewChild		(xmlNodePtr parent, 
    xmlNsPtr ns,
    const xmlChar * name,
    const xmlChar * content)
    -

    Creation of a new child element, added at the end of @parent children list. @ns and @content parameters are optional (NULL). If @ns is NULL, the newly created element inherits the namespace of @parent. If @content is non NULL, a child list containing the TEXTs and ENTITY_REFs node will be created. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references. XML special chars must be escaped first by using xmlEncodeEntitiesReentrant(), or xmlNewTextChild() should be used.

    +

    Create a new child element and append it to a parent element. If @ns is NULL, the newly created element inherits the namespace of the parent. If provided, @content is expected to be a valid XML attribute value possibly containing character and entity references. Text and entity reference node will be added to the child element, see xmlNewDocNode.

    @@ -3330,7 +3365,7 @@

    - + @@ -3338,11 +3373,11 @@

    - + - +
    ns:a namespace if anya namespace (optional)
    name:
    content:the XML content of the child if any.text content with XML references (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3353,17 +3388,17 @@

    xmlNewComment ()

    xmlNodePtr	xmlNewComment		(const xmlChar * content)
    -

    Use of this function is DISCOURAGED in favor of xmlNewDocComment. Creation of a new node containing a comment.

    +

    Use of this function is DISCOURAGED in favor of xmlNewDocComment. Create a comment node.

    - + - +
    content:the comment contentthe comment content (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -3374,18 +3409,17 @@

    xmlNewDoc ()

    xmlDocPtr	xmlNewDoc		(const xmlChar * version)
    -

    Creates a new XML document

    +

    Creates a new XML document. If version is NULL, "1.0" is used.

    - + - +
    version: -xmlChar string giving the version of XML "1.0"XML version string like "1.0" (optional)
    Returns:a new documenta new document or NULL if a memory allocation failed.
    @@ -3396,7 +3430,7 @@

    xmlNewDocComment ()

    xmlNodePtr	xmlNewDocComment	(xmlDocPtr doc, 
    const xmlChar * content)
    -

    Creation of a new node containing a comment within a document.

    +

    Create a comment node.

    @@ -3410,7 +3444,7 @@

    - +
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -3421,17 +3455,17 @@

    xmlNewDocFragment ()

    xmlNodePtr	xmlNewDocFragment	(xmlDocPtr doc)
    -

    Creation of a new Fragment node.

    +

    Create a document fragment node.

    - + - +
    doc:the document owning the fragmentthe target document (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -3442,17 +3476,17 @@

    xmlNewDocNode ()

    xmlNodePtr	xmlNewDocNode		(xmlDocPtr doc, 
    xmlNsPtr ns,
    const xmlChar * name,
    const xmlChar * content)
    -

    Creation of a new node element within a document. @ns and @content are optional (NULL). NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't need entities support.

    +

    Create an element node. If provided, @content is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. Only references are handled, nested elements, comments or PIs are not. See xmlNewDocRawNode for an alternative. General notes on object creation: Each node and all its children are associated with the same document. The document should be provided when creating nodes to avoid a performance penalty when adding the node to a document tree. Note that a document only owns nodes reachable from the root node. Unlinked subtrees must be freed manually.

    - + - + @@ -3460,11 +3494,11 @@

    - + - +
    doc:the documentthe target document
    ns:namespace if anynamespace (optional)
    name:
    content:the XML text content if anytext content with XML references (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3475,17 +3509,17 @@

    xmlNewDocNodeEatName ()

    xmlNodePtr	xmlNewDocNodeEatName	(xmlDocPtr doc, 
    xmlNsPtr ns,
    xmlChar * name,
    const xmlChar * content)
    -

    Creation of a new node element within a document. @ns and @content are optional (NULL). NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't need entities support.

    +

    Create an element node. Like xmlNewDocNode, but the @name string will be used directly without making a copy. Takes ownership of @name which will also be freed on error.

    - + - + @@ -3493,11 +3527,11 @@

    - + - +
    doc:the documentthe target document
    ns:namespace if anynamespace (optional)
    name:
    content:the XML text content if anytext content with XML references (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3508,25 +3542,25 @@

    xmlNewDocPI ()

    xmlNodePtr	xmlNewDocPI		(xmlDocPtr doc, 
    const xmlChar * name,
    const xmlChar * content)
    -

    Creation of a processing instruction element.

    +

    Create a processing instruction object.

    - + - + - + - +
    doc:the target documentthe target document (optional)
    name:the processing instruction namethe processing instruction target
    content:the PI contentthe PI content (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3537,13 +3571,13 @@

    xmlNewDocProp ()

    xmlAttrPtr	xmlNewDocProp		(xmlDocPtr doc, 
    const xmlChar * name,
    const xmlChar * value)
    -

    Create a new property carried by a document. NOTE: @value is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewProp() if you don't need entities support.

    +

    Create an attribute object. If provided, @value is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. If you want to pass a raw string, see xmlNewProp.

    - + @@ -3552,13 +3586,12 @@

    - + - +
    doc:the documentthe target document (optional)
    name:
    value:the value of the attribute - +attribute value with XML references (optional)
    Returns:a pointer to the attribute -a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.
    @@ -3569,17 +3602,17 @@

    xmlNewDocRawNode ()

    xmlNodePtr	xmlNewDocRawNode	(xmlDocPtr doc, 
    xmlNsPtr ns,
    const xmlChar * name,
    const xmlChar * content)
    -

    Creation of a new node element within a document. @ns and @content are optional (NULL).

    +

    Create an element node. If provided, @value should be a raw, unescaped string.

    - + - + @@ -3587,11 +3620,11 @@

    - + - +
    doc:the documentthe target document
    ns:namespace if anynamespace (optional)
    name:
    content:the text content if anyraw text content (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3602,21 +3635,21 @@

    xmlNewDocText ()

    xmlNodePtr	xmlNewDocText		(const xmlDoc * doc, 
    const xmlChar * content)
    -

    Creation of a new text node within a document.

    +

    Create a new text node.

    - + - + - +
    doc:the documentthe target document
    content:the text contentraw text content (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -3627,25 +3660,25 @@

    xmlNewDocTextLen ()

    xmlNodePtr	xmlNewDocTextLen	(xmlDocPtr doc, 
    const xmlChar * content,
    int len)
    -

    Creation of a new text node with an extra content length parameter. The text node pertain to a given document.

    +

    Create a new text node.

    - + - + - + - +
    doc:the documentthe target document
    content:the text contentraw text content (optional)
    len:the text len.size of text content
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -3656,29 +3689,29 @@

    xmlNewDtd ()

    xmlDtdPtr	xmlNewDtd		(xmlDocPtr doc, 
    const xmlChar * name,
    const xmlChar * ExternalID,
    const xmlChar * SystemID)
    -

    Creation of a new DTD for the external subset. To create an internal subset, use xmlCreateIntSubset().

    +

    Create a DTD node. If a document is provided, it is an error if it already has an external subset. If the document has no external subset, it will be set to the created DTD. To create an internal subset, use xmlCreateIntSubset().

    - + - + - + - + - +
    doc:the document pointerthe document pointer (optional)
    name:the DTD namethe DTD name (optional)
    ExternalID:the external IDthe external ID (optional)
    SystemID:the system IDthe system ID (optional)
    Returns:a pointer to the new DTD structurea pointer to the new DTD object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3718,13 +3751,13 @@

    xmlNewNode ()

    xmlNodePtr	xmlNewNode		(xmlNsPtr ns, 
    const xmlChar * name)
    -

    Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of xmlNewDocNode.

    +

    Create an element node. Use of this function is DISCOURAGED in favor of xmlNewDocNode.

    - + @@ -3732,7 +3765,7 @@

    - +
    ns:namespace if anynamespace (optional)
    name:
    Returns:a pointer to the new node object. Uses xmlStrdup() to make copy of @name.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3743,13 +3776,13 @@

    xmlNewNodeEatName ()

    xmlNodePtr	xmlNewNodeEatName	(xmlNsPtr ns, 
    xmlChar * name)
    -

    Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of xmlNewDocNodeEatName.

    +

    Create an element node. Use of this function is DISCOURAGED in favor of xmlNewDocNodeEatName. Like xmlNewNode, but the @name string will be used directly without making a copy. Takes ownership of @name which will also be freed on error.

    - + @@ -3757,7 +3790,7 @@

    - +
    ns:namespace if anynamespace (optional)
    name:
    Returns:a pointer to the new node object, with pointer @name as new node's name. Use xmlNewNode() if a copy of @name string is is needed as new node's name.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3768,13 +3801,13 @@

    xmlNewNs ()

    xmlNsPtr	xmlNewNs		(xmlNodePtr node, 
    const xmlChar * href,
    const xmlChar * prefix)
    -

    Creation of a new Namespace. This function will refuse to create a namespace with a similar prefix than an existing one present on this node. Note that for a default namespace, @prefix should be NULL. We use href==NULL in the case of an element creation where the namespace was not defined.

    +

    Create a new namespace. For a default namespace, @prefix should be NULL. The namespace URI in @href is not checked. You should make sure to pass a valid URI. If @node is provided, it must be an element node. The namespace will be appended to the node's namespace declarations. It is an error if the node already has a definition for the prefix or default namespace.

    - + @@ -3782,11 +3815,11 @@

    - + - +
    node:the element carrying the namespacethe element carrying the namespace (optional)
    href:
    prefix:the prefix for the namespacethe prefix for the namespace (optional)
    Returns:a new namespace pointer or NULLa new namespace pointer or NULL if arguments are invalid, the prefix is already in use or a memory allocation failed.
    @@ -3797,32 +3830,30 @@

    xmlNewNsProp ()

    xmlAttrPtr	xmlNewNsProp		(xmlNodePtr node, 
    xmlNsPtr ns,
    const xmlChar * name,
    const xmlChar * value)
    -

    Create a new property tagged with a namespace and carried by a node.

    +

    Create an attribute object. If provided, @value should be a raw, unescaped string. If @node is provided, the created attribute will be appended without checking for duplicate names. It is an error if @node is not an element.

    - + - + - - + - +
    node:the holding nodethe parent node (optional)
    ns:the namespacethe namespace (optional)
    name:the name of the attribute +the local name of the attribute
    value:the value of the attribute -the value of the attribute (optional)
    Returns:a pointer to the attribute -a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.
    @@ -3833,32 +3864,30 @@

    xmlNewNsPropEatName ()

    xmlAttrPtr	xmlNewNsPropEatName	(xmlNodePtr node, 
    xmlNsPtr ns,
    xmlChar * name,
    const xmlChar * value)
    -

    Create a new property tagged with a namespace and carried by a node.

    +

    Like xmlNewNsProp, but the @name string will be used directly without making a copy. Takes ownership of @name which will also be freed on error.

    - + - + - - + - +
    node:the holding nodethe parent node (optional)
    ns:the namespacethe namespace (optional)
    name:the name of the attribute +the local name of the attribute
    value:the value of the attribute -the value of the attribute (optional)
    Returns:a pointer to the attribute -a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.
    @@ -3869,21 +3898,21 @@

    xmlNewPI ()

    xmlNodePtr	xmlNewPI		(const xmlChar * name, 
    const xmlChar * content)
    -

    Creation of a processing instruction element. Use of this function is DISCOURAGED in favor of xmlNewDocPI.

    +

    Create a processing instruction node. Use of this function is DISCOURAGED in favor of xmlNewDocPI.

    - + - + - +
    name:the processing instruction namethe processing instruction target
    content:the PI contentthe PI content (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3894,13 +3923,13 @@

    xmlNewProp ()

    xmlAttrPtr	xmlNewProp		(xmlNodePtr node, 
    const xmlChar * name,
    const xmlChar * value)
    -

    Create a new property carried by a node.

    +

    Create an attribute node. If provided, @value should be a raw, unescaped string. If @node is provided, the created attribute will be appended without checking for duplicate names. It is an error if @node is not an element.

    - + @@ -3909,13 +3938,11 @@

    - + - +
    node:the holding nodethe parent node (optional)
    name:
    value:the value of the attribute -the value of the attribute (optional)
    Returns:a pointer to the attribute -a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.
    @@ -3926,21 +3953,21 @@

    xmlNewReference ()

    xmlNodePtr	xmlNewReference		(const xmlDoc * doc, 
    const xmlChar * name)
    -

    Creation of a new reference node.

    +

    Create a new entity reference node, linking the result with the entity in @doc if found. Entity names like '&entity;' are handled as well.

    - + - + - +
    doc:the documentthe target document (optional)
    name:the reference name, or the reference string with & and ;the entity name
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -3951,17 +3978,17 @@

    xmlNewText ()

    xmlNodePtr	xmlNewText		(const xmlChar * content)
    -

    Creation of a new text node. Use of this function is DISCOURAGED in favor of xmlNewDocText.

    +

    Create a text node. Use of this function is DISCOURAGED in favor of xmlNewDocText.

    - + - +
    content:the text contentraw text content (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -3972,7 +3999,7 @@

    xmlNewTextChild ()

    xmlNodePtr	xmlNewTextChild		(xmlNodePtr parent, 
    xmlNsPtr ns,
    const xmlChar * name,
    const xmlChar * content)
    -

    Creation of a new child element, added at the end of @parent children list. @ns and @content parameters are optional (NULL). If @ns is NULL, the newly created element inherits the namespace of @parent. If @content is non NULL, a child TEXT node will be created containing the string @content. NOTE: Use xmlNewChild() if @content will contain entities that need to be preserved. Use this function, xmlNewTextChild(), if you need to ensure that reserved XML chars that might appear in @content, such as the ampersand, greater-than or less-than signs, are automatically replaced by their XML escaped entity representations.

    +

    Create a new child element and append it to a parent element. If @ns is NULL, the newly created element inherits the namespace of the parent. If @content is provided, a text node will be added to the child element, see xmlNewDocRawNode.

    @@ -3982,7 +4009,7 @@

    - + @@ -3990,11 +4017,11 @@

    - + - +
    ns:a namespace if anya namespace (optional)
    name:
    content:the text content of the child if any.raw text content of the child (optional)
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.
    @@ -4005,21 +4032,21 @@

    xmlNewTextLen ()

    xmlNodePtr	xmlNewTextLen		(const xmlChar * content, 
    int len)
    -

    Use of this function is DISCOURAGED in favor of xmlNewDocTextLen. Creation of a new text node with an extra parameter for the content's length

    +

    Use of this function is DISCOURAGED in favor of xmlNewDocTextLen.

    - + - + - +
    content:the text contentraw text content (optional)
    len:the text len.size of text content
    Returns:a pointer to the new node object.a pointer to the new node object or NULL if a memory allocation failed.
    @@ -4030,7 +4057,7 @@

    xmlNextElementSibling ()

    xmlNodePtr	xmlNextElementSibling	(xmlNodePtr node)
    -

    Finds the first closest next sibling of the node which is an element node. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references.

    +

    Find the closest following sibling which is a element. Note that entity references are not expanded.

    @@ -4040,7 +4067,7 @@

    - +
    Returns:the next element sibling or NULL if not availablethe sibling or NULL if no sibling was found.
    @@ -4049,7 +4076,7 @@

    xmlNodeAddContent ()

    -
    void	xmlNodeAddContent		(xmlNodePtr cur, 
    const xmlChar * content)
    +
    int	xmlNodeAddContent		(xmlNodePtr cur, 
    const xmlChar * content)

    Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.

    @@ -4063,6 +4090,10 @@

    + + + +
    content: extra content
    Returns:0 on success, 1 on error, -1 if a memory allocation failed.
    @@ -4070,7 +4101,7 @@

    xmlNodeAddContentLen ()

    -
    void	xmlNodeAddContentLen		(xmlNodePtr cur, 
    const xmlChar * content,
    int len)
    +
    int	xmlNodeAddContentLen		(xmlNodePtr cur, 
    const xmlChar * content,
    int len)

    Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.

    @@ -4088,6 +4119,10 @@

    + + + +
    len: the size of @content
    Returns:0 on success, 1 on error, -1 if a memory allocation failed.
    @@ -4193,10 +4228,43 @@


    +xmlNodeGetAttrValue ()

    +
    int	xmlNodeGetAttrValue		(const xmlNode * node, 
    const xmlChar * name,
    const xmlChar * nsUri,
    xmlChar ** out)
    +
    +

    Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. The returned value must be freed by the caller. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + + + + + +
    node:the node
    name:the attribute name
    nsUri:the URI of the namespace
    out:the returned string
    Returns:0 on success, 1 if no attribute was found, -1 if a memory allocation failed.
    +
    +
    +
    +

    xmlNodeGetBase ()

    xmlChar *	xmlNodeGetBase		(const xmlDoc * doc, 
    const xmlNode * cur)
    -

    Searches for the BASE URL. The code should work on both XML and HTML document even if base mechanisms are completely different. It returns the base as defined in RFC 2396 sections 5.1.1. Base URI within Document Content and 5.1.2. Base URI from the Encapsulating Entity However it does not return the document base (5.1.3), use doc->URL in this case

    +

    See xmlNodeGetBaseSafe. This function doesn't allow to distinguish memory allocation failures from a non-existing base.

    @@ -4218,6 +4286,35 @@


    +xmlNodeGetBaseSafe ()

    +
    int	xmlNodeGetBaseSafe		(const xmlDoc * doc, 
    const xmlNode * cur,
    xmlChar ** baseOut)
    +
    +

    Searches for the BASE URL. The code should work on both XML and HTML document even if base mechanisms are completely different. It returns the base as defined in RFC 2396 sections 5.1.1. Base URI within Document Content and 5.1.2. Base URI from the Encapsulating Entity However it does not return the document base (5.1.3), use doc->URL in this case Available since 2.13.0.

    +

    ++ + + + + + + + + + + + + + + + + + +
    doc:the document the node pertains to
    cur:the node being checked
    baseOut:pointer to base
    Returns:0 in case of success, 1 if a URI or argument is invalid, -1 if a memory allocation failed.
    +
    +
    +
    +

    xmlNodeGetContent ()

    xmlChar *	xmlNodeGetContent	(const xmlNode * cur)
    @@ -4305,25 +4402,25 @@

    xmlNodeListGetRawString ()

    xmlChar *	xmlNodeListGetRawString	(const xmlDoc * doc, 
    const xmlNode * list,
    int inLine)
    -

    Builds the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs, contrary to xmlNodeListGetString() this function doesn't do any character encoding handling.

    +

    Serializes attribute children (text and entity reference nodes) into a string. An empty list produces an empty string. If @inLine is true, entity references will be substituted. Otherwise, entity references will be kept and special characters like '&' will be escaped.

    - + - + - + - +
    doc:the documenta document (optional)
    list:a Node lista node list of attribute children (optional)
    inLine:should we replace entity contents or show their external formwhether entity references are substituted
    Returns:a pointer to the string copy, the caller must free it with xmlFree().a string or NULL if a memory allocation failed.
    @@ -4334,25 +4431,25 @@

    xmlNodeListGetString ()

    xmlChar *	xmlNodeListGetString	(xmlDocPtr doc, 
    const xmlNode * list,
    int inLine)
    -

    Build the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs

    +

    Serializes attribute children (text and entity reference nodes) into a string. An empty list produces an empty string. If @inLine is true, entity references will be substituted. Otherwise, entity references will be kept and special characters like '&' as well as non-ASCII chars will be escaped. See xmlNodeListGetRawString for an alternative option.

    - + - + - + - +
    doc:the documenta document (optional)
    list:a Node lista node list of attribute children (optional)
    inLine:should we replace entity contents or show their external formwhether entity references are substituted
    Returns:a pointer to the string copy, the caller must free it with xmlFree().a string or NULL if a memory allocation failed.
    @@ -4361,7 +4458,7 @@

    xmlNodeSetBase ()

    -
    void	xmlNodeSetBase			(xmlNodePtr cur, 
    const xmlChar * uri)
    +
    int	xmlNodeSetBase			(xmlNodePtr cur, 
    const xmlChar * uri)

    Set (or reset) the base URI of a node, i.e. the value of the xml:base attribute.

    @@ -4375,6 +4472,10 @@

    + + + +
    uri: the new base URI
    Returns:0 on success, -1 on error.
    @@ -4382,9 +4483,9 @@

    xmlNodeSetContent ()

    -
    void	xmlNodeSetContent		(xmlNodePtr cur, 
    const xmlChar * content)
    +
    int	xmlNodeSetContent		(xmlNodePtr cur, 
    const xmlChar * content)
    -

    Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().

    +

    Replace the text content of a node. Sets the raw text content of text, CDATA, comment or PI nodes. For element and attribute nodes, removes all children and replaces them by parsing @content which is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. Unfortunately, there isn't an API to pass raw content directly. An inefficient work-around is to escape the content with xmlEncodeSpecialChars before passing it. A better trick is clearing the old content with xmlNodeSetContent(node, NULL) first and then calling xmlNodeAddContent(node, content). Unlike this function, xmlNodeAddContent accepts raw text.

    @@ -4396,6 +4497,10 @@

    + + + +
    content: the new value of the content
    Returns:0 on success, 1 on error, -1 if a memory allocation failed.
    @@ -4403,9 +4508,9 @@

    xmlNodeSetContentLen ()

    -
    void	xmlNodeSetContentLen		(xmlNodePtr cur, 
    const xmlChar * content,
    int len)
    +
    int	xmlNodeSetContentLen		(xmlNodePtr cur, 
    const xmlChar * content,
    int len)
    -

    Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().

    +

    See xmlNodeSetContent.

    @@ -4421,6 +4526,10 @@

    + + + +
    len: the size of @content
    Returns:0 on success, 1 on error, -1 if a memory allocation failed.
    @@ -4428,7 +4537,7 @@

    xmlNodeSetLang ()

    -
    void	xmlNodeSetLang			(xmlNodePtr cur, 
    const xmlChar * lang)
    +
    int	xmlNodeSetLang			(xmlNodePtr cur, 
    const xmlChar * lang)

    Set the language of a node, i.e. the values of the xml:lang attribute.

    @@ -4442,6 +4551,10 @@

    + + + +
    lang: the language description
    Returns:0 on success, 1 if arguments are invalid, -1 if a memory allocation failed.
    @@ -4470,7 +4583,7 @@

    xmlNodeSetSpacePreserve ()

    -
    void	xmlNodeSetSpacePreserve		(xmlNodePtr cur, 
    int val)
    +
    int	xmlNodeSetSpacePreserve		(xmlNodePtr cur, 
    int val)

    Set (or reset) the space preserving behaviour of a node, i.e. the value of the xml:space attribute.

    @@ -4484,6 +4597,10 @@

    + + + +
    val: the xml:space value ("0": default, 1: "preserve")
    Returns:0 on success, 1 if arguments are invalid, -1 if a memory allocation failed.
    @@ -4493,7 +4610,7 @@

    xmlPreviousElementSibling ()

    xmlNodePtr	xmlPreviousElementSibling	(xmlNodePtr node)
    -

    Finds the first closest previous sibling of the node which is an element node. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references.

    +

    Find the closest preceding sibling which is a element. Note that entity references are not expanded.

    @@ -4503,7 +4620,7 @@

    - +
    Returns:the previous element sibling or NULL if not availablethe sibling or NULL if no sibling was found.
    @@ -4528,7 +4645,7 @@

    Returns: -the number of namespace declarations created or -1 in case of error. +0 on success or -1 in case of error.

    @@ -4539,7 +4656,7 @@

    xmlRegisterNodeDefault ()

    xmlRegisterNodeFunc	xmlRegisterNodeDefault	(xmlRegisterNodeFunc func)
    -

    Registers a callback for node creation

    +

    DEPRECATED: don't use Registers a callback for node creation

    @@ -4560,7 +4677,7 @@

    xmlRemoveProp ()

    int	xmlRemoveProp			(xmlAttrPtr cur)
    -

    Unlink and free one attribute, all the content is freed too Note this doesn't work for namespace definition attributes

    +

    Unlink and free an attribute including all children. Note this doesn't work for namespace declarations. The attribute must have a non-NULL parent pointer.

    @@ -4571,7 +4688,7 @@

    - +
    Returns:0 if success and -1 in case of error.0 on success or -1 if the attribute was not found or arguments are invalid.
    @@ -4582,7 +4699,7 @@

    xmlReplaceNode ()

    xmlNodePtr	xmlReplaceNode		(xmlNodePtr old, 
    xmlNodePtr cur)
    -

    Unlink the old node from its current context, prune the new one at the same place. If @cur was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in xmlAddChild.

    +

    Unlink the old node. If @cur is provided, it is unlinked and inserted in place of @old. It is an error if @old has no parent. Unlike xmlAddChild, this function doesn't merge text nodes or delete duplicate attributes. See the notes in xmlAddChild.

    @@ -4592,11 +4709,11 @@

    - + - +
    cur:the nodethe node (optional)
    Returns:the @old node@old or NULL if arguments are invalid or a memory allocation failed.
    @@ -4803,7 +4920,7 @@

    Returns: -the namespace pointer or NULL. +the namespace pointer or NULL if no namespace was found or a memory allocation failed. Allocations can only fail if the "xml" namespace is queried.

    @@ -4832,7 +4949,7 @@

    Returns: -the namespace pointer or NULL. +the namespace pointer or NULL if no namespace was found or a memory allocation failed. Allocations can only fail if the "xml" namespace is queried.

    @@ -4858,7 +4975,7 @@

    xmlSetCompressMode ()

    void	xmlSetCompressMode		(int mode)
    -

    set the default compression mode used, ZLIB based Correct values: 0 (uncompressed) to 9 (max compression)

    +

    DEPRECATED: Use xmlSetDocCompressMode set the default compression mode used, ZLIB based Correct values: 0 (uncompressed) to 9 (max compression)

    @@ -4892,19 +5009,23 @@

    xmlSetListDoc ()

    -
    void	xmlSetListDoc			(xmlNodePtr list, 
    xmlDocPtr doc)
    +
    int	xmlSetListDoc			(xmlNodePtr list, 
    xmlDocPtr doc)
    -

    update all nodes in the list to point to the right document

    +

    Associate all subtrees in @list with a new document. Internal function, see xmlSetTreeDoc.

    - + - + + + + +
    list:the first elementa node list
    doc:the documentnew document
    Returns:0 on success. If a memory allocation fails, returns -1. All subtrees will be updated on failure but some strings may be lost.
    @@ -4915,7 +5036,7 @@

    xmlSetNs ()

    void	xmlSetNs			(xmlNodePtr node, 
    xmlNsPtr ns)
    -

    Associate a namespace to a node, a posteriori.

    +

    Set the namespace of an element or attribute node. Passing a NULL namespace unsets the namespace.

    @@ -4925,7 +5046,7 @@

    - +
    ns:a namespace pointera namespace pointer (optional)
    @@ -4996,19 +5117,23 @@

    xmlSetTreeDoc ()

    -
    void	xmlSetTreeDoc			(xmlNodePtr tree, 
    xmlDocPtr doc)
    +
    int	xmlSetTreeDoc			(xmlNodePtr tree, 
    xmlDocPtr doc)
    -

    update all nodes under the tree to point to the right document

    +

    This is an internal function which shouldn't be used. It is invoked by functions like xmlAddChild, xmlAddSibling or xmlReplaceNode. @tree must be the root node of an unlinked subtree. Associate all nodes in a tree with a new document. Also copy strings from the old document's dictionary and remove ID attributes from the old ID table.

    - + - + + + + +
    tree:the top elementroot of a subtree
    doc:the documentnew document
    Returns:0 on success. If a memory allocation fails, returns -1. The whole tree will be updated on failure but some strings may be lost.
    @@ -5019,7 +5144,7 @@

    xmlSplitQName2 ()

    xmlChar *	xmlSplitQName2		(const xmlChar * name, 
    xmlChar ** prefix)
    -

    parse an XML qualified name string [NS 5] QName ::= (Prefix ':')? LocalPart [NS 6] Prefix ::= NCName [NS 7] LocalPart ::= NCName

    +

    DEPRECATED: This function doesn't report malloc failures. parse an XML qualified name string [NS 5] QName ::= (Prefix ':')? LocalPart [NS 6] Prefix ::= NCName [NS 7] LocalPart ::= NCName

    @@ -5069,22 +5194,21 @@

    xmlStringGetNodeList ()

    xmlNodePtr	xmlStringGetNodeList	(const xmlDoc * doc, 
    const xmlChar * value)
    -

    Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs.

    +

    DEPRECATED: Use xmlNodeSetContent. Parse an attribute value and build a node list containing only text and entity reference nodes. The resulting nodes will be associated with the document if provided. The document is also used to look up entities. The input is not validated. Syntax errors or references to undeclared entities will be ignored silently with unspecified results.

    - + - + - +
    doc:the documenta document (optional)
    value:the value of the attribute -an attribute value
    Returns:a pointer to the first childa pointer to the first child or NULL if a memory allocation failed.
    @@ -5095,25 +5219,25 @@

    xmlStringLenGetNodeList ()

    xmlNodePtr	xmlStringLenGetNodeList	(const xmlDoc * doc, 
    const xmlChar * value,
    int len)
    -

    Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs.

    +

    DEPRECATED: Use xmlNodeSetContentLen. See xmlStringGetNodeList.

    - + - + - + - +
    doc:the documenta document (optional)
    value:the value of the textan attribute value
    len:the length of the string valuemaximum length of the attribute value
    Returns:a pointer to the first childa pointer to the first child or NULL if a memory allocation failed.
    @@ -5124,7 +5248,7 @@

    xmlTextConcat ()

    int	xmlTextConcat			(xmlNodePtr node, 
    const xmlChar * content,
    int len)
    -

    Concat the given string at the end of the existing node content

    +

    Concat the given string at the end of the existing node content. If @len is -1, the string length will be calculated.

    @@ -5153,7 +5277,7 @@

    xmlTextMerge ()

    xmlNodePtr	xmlTextMerge		(xmlNodePtr first, 
    xmlNodePtr second)
    -

    Merge two text nodes into one

    +

    Merge the second text node into the first. The second node is unlinked and freed.

    @@ -5167,7 +5291,7 @@

    - +
    Returns:the first text node augmentedthe first text node augmented or NULL in case of error.
    @@ -5262,7 +5386,7 @@

    xmlUnlinkNode ()

    void	xmlUnlinkNode			(xmlNodePtr cur)
    -

    Unlink a node from it's current context, the node is not freed If one need to free the node, use xmlFreeNode() routine after the unlink to discard it. Note that namespace nodes can't be unlinked as they do not have pointer to their parent.

    +

    Unlink a node from its tree. The node is not freed. Unless it is reinserted, it must be managed manually and freed eventually by calling xmlFreeNode.

    diff --git a/doc/devhelp/libxml2-uri.html b/doc/devhelp/libxml2-uri.html index de7a0aa44..04f908998 100644 --- a/doc/devhelp/libxml2-uri.html +++ b/doc/devhelp/libxml2-uri.html @@ -25,7 +25,9 @@

    Synopsis

    typedef struct _xmlURI xmlURI;
     typedef xmlURI * xmlURIPtr;
     xmlChar *	xmlBuildRelativeURI	(const xmlChar * URI, 
    const xmlChar * base); +int xmlBuildRelativeURISafe (const xmlChar * URI,
    const xmlChar * base,
    xmlChar ** valPtr); xmlChar * xmlBuildURI (const xmlChar * URI,
    const xmlChar * base); +int xmlBuildURISafe (const xmlChar * URI,
    const xmlChar * base,
    xmlChar ** valPtr); xmlChar * xmlCanonicPath (const xmlChar * path); xmlURIPtr xmlCreateURI (void); void xmlFreeURI (xmlURIPtr uri); @@ -33,6 +35,7 @@

    Synopsis

    xmlURIPtr xmlParseURI (const char * str); xmlURIPtr xmlParseURIRaw (const char * str,
    int raw); int xmlParseURIReference (xmlURIPtr uri,
    const char * str); +int xmlParseURISafe (const char * str,
    xmlURIPtr * uriOut); xmlChar * xmlPathToURI (const xmlChar * path); void xmlPrintURI (FILE * stream,
    xmlURIPtr uri); xmlChar * xmlSaveUri (xmlURIPtr uri); @@ -78,7 +81,7 @@

    xmlBuildRelativeURI ()

    xmlChar *	xmlBuildRelativeURI	(const xmlChar * URI, 
    const xmlChar * base)
    -

    Expresses the URI of the reference in terms relative to the base. Some examples of this operation include: base = "http://site1.com/docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif Note: if the URI reference is really weird or complicated, it may be worthwhile to first convert it into a "nice" one by calling xmlBuildURI (using 'base') before calling this routine, since this routine (for reasonable efficiency) assumes URI has already been through some validation.

    +

    See xmlBuildRelativeURISafe.

    @@ -100,6 +103,35 @@


    +xmlBuildRelativeURISafe ()

    +
    int	xmlBuildRelativeURISafe		(const xmlChar * URI, 
    const xmlChar * base,
    xmlChar ** valPtr)
    +
    +

    Expresses the URI of the reference in terms relative to the base. Some examples of this operation include: base = "http://site1.com/docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif Note: if the URI reference is really weird or complicated, it may be worthwhile to first convert it into a "nice" one by calling xmlBuildURI (using 'base') before calling this routine, since this routine (for reasonable efficiency) assumes URI has already been through some validation. Available since 2.13.0.

    +

    ++ + + + + + + + + + + + + + + + + + +
    URI:the URI reference under consideration
    base:the base value
    valPtr:pointer to result URI
    Returns:0 on success, -1 if a memory allocation failed or an error code if URI or base are invalid.
    +
    +
    +
    +

    xmlBuildURI ()

    xmlChar *	xmlBuildURI		(const xmlChar * URI, 
    const xmlChar * base)
    @@ -125,10 +157,39 @@


    +xmlBuildURISafe ()

    +
    int	xmlBuildURISafe			(const xmlChar * URI, 
    const xmlChar * base,
    xmlChar ** valPtr)
    +
    +

    Computes he final URI of the reference done by checking that the given URI is valid, and building the final URI using the base URI. This is processed according to section 5.2 of the RFC 2396 5.2. Resolving Relative References to Absolute Form Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + + + + + +
    URI:the URI instance found in the document
    base:the base value
    valPtr:pointer to result URI
    Returns:0 on success, -1 if a memory allocation failed or an error code if URI or base are invalid.
    +
    +
    +
    +

    xmlCanonicPath ()

    xmlChar *	xmlCanonicPath		(const xmlChar * path)
    -

    Constructs a canonic path from the specified path.

    +

    Prepares a path. If the path contains the substring "://", it is considered a Legacy Extended IRI. Characters which aren't allowed in URIs are escaped. Otherwise, the path is considered a filesystem path which is copied without modification. The caller is responsible for freeing the memory occupied by the returned string. If there is insufficient memory available, or the argument is NULL, the function returns NULL.

    @@ -138,7 +199,7 @@

    - +
    Returns:a new canonic path, or a duplicate of the path parameter if the construction fails. The caller is responsible for freeing the memory occupied by the returned string. If there is insufficient memory available, or the argument is NULL, the function returns NULL.the escaped path.
    @@ -269,6 +330,31 @@


    +xmlParseURISafe ()

    +
    int	xmlParseURISafe			(const char * str, 
    xmlURIPtr * uriOut)
    +
    +

    Parse an URI based on RFC 3986 URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + +
    str:the URI string to analyze
    uriOut:optional pointer to parsed URI
    Returns:0 on success, an error code (typically 1) if the URI is invalid or -1 if a memory allocation failed.
    +
    +
    +
    +

    xmlPathToURI ()

    xmlChar *	xmlPathToURI		(const xmlChar * path)
    @@ -358,7 +444,7 @@

    xmlURIEscapeStr ()

    xmlChar *	xmlURIEscapeStr		(const xmlChar * str, 
    const xmlChar * list)
    -

    This routine escapes a string to hex, ignoring reserved characters (a-z, A-Z, 0-9, "@-_.!~*'()") and the characters in the exception list.

    +

    This routine escapes a string to hex, ignoring unreserved characters a-z, A-Z, 0-9, "-._~", a few sub-delims "!*'()", the gen-delim "@" (why?) and the characters in the exception list.

    diff --git a/doc/devhelp/libxml2-valid.html b/doc/devhelp/libxml2-valid.html index 7f488dd7c..a66eb8f51 100644 --- a/doc/devhelp/libxml2-valid.html +++ b/doc/devhelp/libxml2-valid.html @@ -39,6 +39,7 @@

    Synopsis

    xmlAttributePtrxmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
    xmlDtdPtr dtd,
    const xmlChar * elem,
    const xmlChar * name,
    const xmlChar * ns,
    xmlAttributeType type,
    xmlAttributeDefault def,
    const xmlChar * defaultValue,
    xmlEnumerationPtr tree); xmlElementPtrxmlAddElementDecl (xmlValidCtxtPtr ctxt,
    xmlDtdPtr dtd,
    const xmlChar * name,
    xmlElementTypeVal type,
    xmlElementContentPtr content); xmlIDPtrxmlAddID (xmlValidCtxtPtr ctxt,
    xmlDocPtr doc,
    const xmlChar * value,
    xmlAttrPtr attr); +int xmlAddIDSafe (xmlAttrPtr attr,
    const xmlChar * value); xmlNotationPtrxmlAddNotationDecl (xmlValidCtxtPtr ctxt,
    xmlDtdPtr dtd,
    const xmlChar * name,
    const xmlChar * PublicID,
    const xmlChar * SystemID); xmlRefPtrxmlAddRef (xmlValidCtxtPtr ctxt,
    xmlDocPtr doc,
    const xmlChar * value,
    xmlAttrPtr attr); xmlAttributeTablePtrxmlCopyAttributeTable (xmlAttributeTablePtr table); @@ -433,6 +434,31 @@


    +xmlAddIDSafe ()

    +
    int	xmlAddIDSafe			(xmlAttrPtr attr, 
    const xmlChar * value)
    +
    +

    Register a new id declaration Available since 2.13.0.

    +

    ++ + + + + + + + + + + + + + +
    attr:the attribute holding the ID
    value:the attribute (ID) value
    Returns:1 on success, 0 if the ID already exists, -1 if a memory allocation fails.
    +
    +
    +
    +

    xmlAddNotationDecl ()

    xmlNotationPtr	xmlAddNotationDecl	(xmlValidCtxtPtr ctxt, 
    xmlDtdPtr dtd,
    const xmlChar * name,
    const xmlChar * PublicID,
    const xmlChar * SystemID)
    @@ -658,7 +684,7 @@

    xmlDumpAttributeDecl ()

    void	xmlDumpAttributeDecl		(xmlBufferPtr buf, 
    xmlAttributePtr attr)
    -

    This will dump the content of the attribute declaration as an XML DTD definition

    +

    DEPRECATED: Use xmlSaveTree. This will dump the content of the attribute declaration as an XML DTD definition

    @@ -679,7 +705,7 @@

    xmlDumpAttributeTable ()

    void	xmlDumpAttributeTable		(xmlBufferPtr buf, 
    xmlAttributeTablePtr table)
    -

    This will dump the content of the attribute table as an XML DTD definition

    +

    DEPRECATED: Don't use. This will dump the content of the attribute table as an XML DTD definition

    @@ -700,7 +726,7 @@

    xmlDumpElementDecl ()

    void	xmlDumpElementDecl		(xmlBufferPtr buf, 
    xmlElementPtr elem)
    -

    This will dump the content of the element declaration as an XML DTD definition

    +

    DEPRECATED: Use xmlSaveTree. This will dump the content of the element declaration as an XML DTD definition

    @@ -721,7 +747,7 @@

    xmlDumpElementTable ()

    void	xmlDumpElementTable		(xmlBufferPtr buf, 
    xmlElementTablePtr table)
    -

    This will dump the content of the element table as an XML DTD definition

    +

    DEPRECATED: Don't use. This will dump the content of the element table as an XML DTD definition

    @@ -742,7 +768,7 @@

    xmlDumpNotationDecl ()

    void	xmlDumpNotationDecl		(xmlBufferPtr buf, 
    xmlNotationPtr nota)
    -

    This will dump the content the notation declaration as an XML DTD definition

    +

    DEPRECATED: Don't use. This will dump the content the notation declaration as an XML DTD definition

    @@ -763,7 +789,7 @@

    xmlDumpNotationTable ()

    void	xmlDumpNotationTable		(xmlBufferPtr buf, 
    xmlNotationTablePtr table)
    -

    This will dump the content of the notation table as an XML DTD definition

    +

    DEPRECATED: Don't use. This will dump the content of the notation table as an XML DTD definition

    @@ -954,7 +980,7 @@

    xmlGetDtdElementDesc ()

    xmlElementPtr	xmlGetDtdElementDesc	(xmlDtdPtr dtd, 
    const xmlChar * name)
    -

    Search the DTD for the description of this element

    +

    Search the DTD for the description of this element NOTE: A NULL return value can also mean that a memory allocation failed.

    @@ -1136,7 +1162,7 @@

    - +
    Returns:0 or 1 depending on the lookup result0 or 1 depending on the lookup result or -1 if a memory allocation failed.
    @@ -1378,7 +1404,7 @@

    xmlValidBuildContentModel ()

    int	xmlValidBuildContentModel	(xmlValidCtxtPtr ctxt, 
    xmlElementPtr elem)
    -

    (Re)Build the automata associated to the content model of this element

    +

    DEPRECATED: Internal function, don't use. (Re)Build the automata associated to the content model of this element

    @@ -1403,7 +1429,7 @@

    xmlValidCtxtNormalizeAttributeValue ()

    xmlChar *	xmlValidCtxtNormalizeAttributeValue	(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlNodePtr elem,
    const xmlChar * name,
    const xmlChar * value)
    -

    Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character. Also check VC: Standalone Document Declaration in P32, and update ctxt->valid accordingly

    +

    DEPRECATED: Internal function, don't use. Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character. Also check VC: Standalone Document Declaration in P32, and update ctxt->valid accordingly

    @@ -1506,7 +1532,7 @@

    xmlValidNormalizeAttributeValue ()

    xmlChar *	xmlValidNormalizeAttributeValue	(xmlDocPtr doc, 
    xmlNodePtr elem,
    const xmlChar * name,
    const xmlChar * value)
    -

    Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character.

    +

    DEPRECATED: Internal function, don't use. Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character.

    @@ -1539,7 +1565,7 @@

    xmlValidateAttributeDecl ()

    int	xmlValidateAttributeDecl	(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlAttributePtr attr)
    -

    Try to validate a single attribute definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Default Legal ] - [ VC: Enumeration ] - [ VC: ID Attribute Default ] The ID/IDREF uniqueness and matching are done separately

    +

    DEPRECATED: Internal function, don't use. Try to validate a single attribute definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Default Legal ] - [ VC: Enumeration ] - [ VC: ID Attribute Default ] The ID/IDREF uniqueness and matching are done separately

    @@ -1568,7 +1594,7 @@

    xmlValidateAttributeValue ()

    int	xmlValidateAttributeValue	(xmlAttributeType type, 
    const xmlChar * value)
    -

    Validate that the given attribute value match the proper production [ VC: ID ] Values of type ID must match the Name production.... [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names ... [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names ... [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.

    +

    DEPRECATED: Internal function, don't use. Validate that the given attribute value match the proper production [ VC: ID ] Values of type ID must match the Name production.... [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names ... [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names ... [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.

    @@ -1618,7 +1644,7 @@

    xmlValidateDocumentFinal ()

    int	xmlValidateDocumentFinal	(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc)
    -

    Does the final step for the document validation once all the incremental validation steps have been completed basically it does the following checks described by the XML Rec Check all the IDREF/IDREFS attributes definition for validity

    +

    DEPRECATED: Internal function, don't use. Does the final step for the document validation once all the incremental validation steps have been completed basically it does the following checks described by the XML Rec Check all the IDREF/IDREFS attributes definition for validity

    @@ -1672,7 +1698,7 @@

    xmlValidateDtdFinal ()

    int	xmlValidateDtdFinal		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc)
    -

    Does the final step for the dtds validation once all the subsets have been parsed basically it does the following checks described by the XML Rec - check that ENTITY and ENTITIES type attributes default or possible values matches one of the defined entities. - check that NOTATION type attributes default or possible values matches one of the defined notations.

    +

    DEPRECATED: Internal function, don't use. Does the final step for the dtds validation once all the subsets have been parsed basically it does the following checks described by the XML Rec - check that ENTITY and ENTITIES type attributes default or possible values matches one of the defined entities. - check that NOTATION type attributes default or possible values matches one of the defined notations.

    @@ -1726,7 +1752,7 @@

    xmlValidateElementDecl ()

    int	xmlValidateElementDecl		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlElementPtr elem)
    -

    Try to validate a single element definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: One ID per Element Type ] - [ VC: No Duplicate Types ] - [ VC: Unique Element Type Declaration ]

    +

    DEPRECATED: Internal function, don't use. Try to validate a single element definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: One ID per Element Type ] - [ VC: No Duplicate Types ] - [ VC: Unique Element Type Declaration ]

    @@ -1839,7 +1865,7 @@

    xmlValidateNotationDecl ()

    int	xmlValidateNotationDecl		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlNotationPtr nota)
    -

    Try to validate a single notation definition basically it does the following checks as described by the XML-1.0 recommendation: - it seems that no validity constraint exists on notation declarations But this function get called anyway ...

    +

    DEPRECATED: Internal function, don't use. Try to validate a single notation definition basically it does the following checks as described by the XML-1.0 recommendation: - it seems that no validity constraint exists on notation declarations But this function get called anyway ...

    @@ -1868,7 +1894,7 @@

    xmlValidateNotationUse ()

    int	xmlValidateNotationUse		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    const xmlChar * notationName)
    -

    Validate that the given name match a notation declaration. - [ VC: Notation Declared ]

    +

    DEPRECATED: Internal function, don't use. Validate that the given name match a notation declaration. - [ VC: Notation Declared ]

    @@ -1897,7 +1923,7 @@

    xmlValidateOneAttribute ()

    int	xmlValidateOneAttribute		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlNodePtr elem,
    xmlAttrPtr attr,
    const xmlChar * value)
    -

    Try to validate a single attribute for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately

    +

    DEPRECATED: Internal function, don't use. Try to validate a single attribute for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately

    @@ -1934,7 +1960,7 @@

    xmlValidateOneElement ()

    int	xmlValidateOneElement		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlNodePtr elem)
    -

    Try to validate a single element and it's attributes, basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Element Valid ] - [ VC: Required Attribute ] Then call xmlValidateOneAttribute() for each attribute present. The ID/IDREF checkings are done separately

    +

    DEPRECATED: Internal function, don't use. Try to validate a single element and it's attributes, basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Element Valid ] - [ VC: Required Attribute ] Then call xmlValidateOneAttribute() for each attribute present. The ID/IDREF checkings are done separately

    @@ -1963,7 +1989,7 @@

    xmlValidateOneNamespace ()

    int	xmlValidateOneNamespace		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlNodePtr elem,
    const xmlChar * prefix,
    xmlNsPtr ns,
    const xmlChar * value)
    -

    Try to validate a single namespace declaration for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately

    +

    DEPRECATED: Internal function, don't use. Try to validate a single namespace declaration for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately

    @@ -2004,7 +2030,7 @@

    xmlValidatePopElement ()

    int	xmlValidatePopElement		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlNodePtr elem,
    const xmlChar * qname)
    -

    Pop the element end from the validation stack.

    +

    DEPRECATED: Internal function, don't use. Pop the element end from the validation stack.

    @@ -2037,7 +2063,7 @@

    xmlValidatePushCData ()

    int	xmlValidatePushCData		(xmlValidCtxtPtr ctxt, 
    const xmlChar * data,
    int len)
    -

    check the CData parsed for validation in the current stack

    +

    DEPRECATED: Internal function, don't use. check the CData parsed for validation in the current stack

    @@ -2066,7 +2092,7 @@

    xmlValidatePushElement ()

    int	xmlValidatePushElement		(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc,
    xmlNodePtr elem,
    const xmlChar * qname)
    -

    Push a new element start on the validation stack.

    +

    DEPRECATED: Internal function, don't use. Push a new element start on the validation stack.

    @@ -2099,7 +2125,7 @@

    xmlValidateRoot ()

    int	xmlValidateRoot			(xmlValidCtxtPtr ctxt, 
    xmlDocPtr doc)
    -

    Try to validate a the root element basically it does the following check as described by the XML-1.0 recommendation: - [ VC: Root Element Type ] it doesn't try to recurse or apply other check to the element

    +

    DEPRECATED: Internal function, don't use. Try to validate a the root element basically it does the following check as described by the XML-1.0 recommendation: - [ VC: Root Element Type ] it doesn't try to recurse or apply other check to the element

    diff --git a/doc/devhelp/libxml2-xinclude.html b/doc/devhelp/libxml2-xinclude.html index 6b9582664..eba01b74c 100644 --- a/doc/devhelp/libxml2-xinclude.html +++ b/doc/devhelp/libxml2-xinclude.html @@ -35,6 +35,7 @@

    Synopsis

    typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt; typedef xmlXIncludeCtxt * xmlXIncludeCtxtPtr; void xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt); +int xmlXIncludeGetLastError (xmlXIncludeCtxtPtr ctxt); xmlXIncludeCtxtPtrxmlXIncludeNewContext (xmlDocPtr doc); int xmlXIncludeProcess (xmlDocPtr doc); int xmlXIncludeProcessFlags (xmlDocPtr doc,
    int flags); @@ -43,6 +44,7 @@

    Synopsis

    int xmlXIncludeProcessTree (xmlNodePtr tree); int xmlXIncludeProcessTreeFlags (xmlNodePtr tree,
    int flags); int xmlXIncludeProcessTreeFlagsData (xmlNodePtr tree,
    int flags,
    void * data); +void xmlXIncludeSetErrorHandler (xmlXIncludeCtxtPtr ctxt,
    xmlStructuredErrorFunc handler,
    void * data); int xmlXIncludeSetFlags (xmlXIncludeCtxtPtr ctxt,
    int flags); @@ -165,6 +167,27 @@


    +xmlXIncludeGetLastError ()

    +
    int	xmlXIncludeGetLastError		(xmlXIncludeCtxtPtr ctxt)
    +
    +

    Available since 2.13.0.

    +

    ++ + + + + + + + + + +
    ctxt:an XInclude processing context
    Returns:the last error code.
    +
    +
    +
    +

    xmlXIncludeNewContext ()

    xmlXIncludeCtxtPtr	xmlXIncludeNewContext	(xmlDocPtr doc)
    @@ -361,6 +384,31 @@


    +xmlXIncludeSetErrorHandler ()

    +
    void	xmlXIncludeSetErrorHandler	(xmlXIncludeCtxtPtr ctxt, 
    xmlStructuredErrorFunc handler,
    void * data)
    +
    +

    Register a callback function that will be called on errors and warnings. If handler is NULL, the error handler will be deactivated. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + +
    ctxt:an XInclude processing context
    handler:error handler
    data:user data which will be passed to the handler
    +
    +
    +
    +

    xmlXIncludeSetFlags ()

    int	xmlXIncludeSetFlags		(xmlXIncludeCtxtPtr ctxt, 
    int flags)
    diff --git a/doc/devhelp/libxml2-xmlIO.html b/doc/devhelp/libxml2-xmlIO.html index a8cc38c1a..cd8424f34 100644 --- a/doc/devhelp/libxml2-xmlIO.html +++ b/doc/devhelp/libxml2-xmlIO.html @@ -357,13 +357,13 @@

    xmlAllocParserInputBuffer ()

    xmlParserInputBufferPtr	xmlAllocParserInputBuffer	(xmlCharEncoding enc)
    -

    Create a buffered parser input for progressive parsing

    +

    Create a buffered parser input for progressive parsing. The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on.

    - + @@ -378,7 +378,7 @@

    xmlCheckFilename ()

    int	xmlCheckFilename		(const char * path)
    -

    function checks to see if @path is a valid source (file, socket...) for XML. if stat is not available on the target machine,

    +

    DEPRECATED: Internal function, don't use. if stat is not available on the target machine,

    enc:the charset encoding if knownthe charset encoding if known (deprecated)
    Returns:
    @@ -399,7 +399,7 @@

    xmlCheckHTTPInput ()

    xmlParserInputPtr	xmlCheckHTTPInput	(xmlParserCtxtPtr ctxt, 
    xmlParserInputPtr ret)
    -

    Check an input in case it was created from an HTTP stream, in that case it will handle encoding and update of the base URL in case of redirection. It also checks for HTTP errors in which case the input is cleanly freed up and an appropriate error is raised in context

    +

    DEPRECATED: Internal function, don't use. Check an input in case it was created from an HTTP stream, in that case it will handle encoding and update of the base URL in case of redirection. It also checks for HTTP errors in which case the input is cleanly freed up and an appropriate error is raised in context

    @@ -440,7 +440,7 @@

    xmlFileClose ()

    int	xmlFileClose			(void * context)
    -

    Close an I/O channel

    +

    DEPRECATED: Internal function, don't use.

    @@ -450,7 +450,7 @@

    - +
    Returns:0 or -1 in case of error0 or -1 an error code case of error
    @@ -461,7 +461,7 @@

    xmlFileMatch ()

    int	xmlFileMatch			(const char * filename)
    -

    input from FILE *

    +

    DEPRECATED: Internal function, don't use.

    @@ -482,7 +482,7 @@

    xmlFileOpen ()

    void *	xmlFileOpen			(const char * filename)
    -

    Wrapper around xmlFileOpen_real that try it with an unescaped version of @filename, if this fails fallback to @filename

    +

    DEPRECATED: Internal function, don't use.

    @@ -492,7 +492,7 @@

    - +
    Returns:a handler or NULL in case or failurean IO context or NULL in case or failure
    @@ -503,7 +503,7 @@

    xmlFileRead ()

    int	xmlFileRead			(void * context, 
    char * buffer,
    int len)
    -

    Read @len bytes to @buffer from the I/O channel.

    +

    DEPRECATED: Internal function, don't use.

    @@ -521,7 +521,7 @@

    - +
    Returns:the number of bytes written or < 0 in case of failurethe number of bytes read or < 0 in case of failure
    @@ -547,7 +547,7 @@

    xmlIOFTPClose ()

    int	xmlIOFTPClose			(void * context)
    -

    Close an FTP I/O channel

    +

    DEPRECATED: Internal function, don't use. Close an FTP I/O channel

    @@ -568,7 +568,7 @@

    xmlIOFTPMatch ()

    int	xmlIOFTPMatch			(const char * filename)
    -

    check if the URI matches an FTP one

    +

    DEPRECATED: Internal function, don't use. check if the URI matches an FTP one

    @@ -589,7 +589,7 @@

    xmlIOFTPOpen ()

    void *	xmlIOFTPOpen			(const char * filename)
    -

    open an FTP I/O channel

    +

    DEPRECATED: Internal function, don't use. open an FTP I/O channel

    @@ -610,7 +610,7 @@

    xmlIOFTPRead ()

    int	xmlIOFTPRead			(void * context, 
    char * buffer,
    int len)
    -

    Read @len bytes to @buffer from the I/O channel.

    +

    DEPRECATED: Internal function, don't use. Read @len bytes to @buffer from the I/O channel.

    @@ -639,7 +639,7 @@

    xmlIOHTTPClose ()

    int	xmlIOHTTPClose			(void * context)
    -

    Close an HTTP I/O channel

    +

    DEPRECATED: Internal function, don't use. Close an HTTP I/O channel

    @@ -660,7 +660,7 @@

    xmlIOHTTPMatch ()

    int	xmlIOHTTPMatch			(const char * filename)
    -

    check if the URI matches an HTTP one

    +

    DEPRECATED: Internal function, don't use. check if the URI matches an HTTP one

    @@ -681,7 +681,7 @@

    xmlIOHTTPOpen ()

    void *	xmlIOHTTPOpen			(const char * filename)
    -

    open an HTTP I/O channel

    +

    DEPRECATED: Internal function, don't use. open an HTTP I/O channel

    @@ -702,7 +702,7 @@

    xmlIOHTTPOpenW ()

    void *	xmlIOHTTPOpenW			(const char * post_uri, 
    int compression)
    -

    Open a temporary buffer to collect the document for a subsequent HTTP POST request. Non-static as is called from the output buffer creation routine.

    +

    DEPRECATED: Support for HTTP POST has been removed.

    @@ -716,7 +716,7 @@

    - +
    Returns:an I/O context or NULL in case of error.NULL.
    @@ -727,7 +727,7 @@

    xmlIOHTTPRead ()

    int	xmlIOHTTPRead			(void * context, 
    char * buffer,
    int len)
    -

    Read @len bytes to @buffer from the I/O channel.

    +

    DEPRECATED: Internal function, don't use. Read @len bytes to @buffer from the I/O channel.

    @@ -785,7 +785,7 @@

    xmlNormalizeWindowsPath ()

    xmlChar *	xmlNormalizeWindowsPath	(const xmlChar * path)
    -

    This function is obsolete. Please see xmlURIFromPath in uri.c for a better solution.

    +

    DEPRECATED: This never really worked.

    @@ -795,7 +795,7 @@

    - +
    Returns:a canonicalized version of the patha copy of path.
    @@ -816,7 +816,7 @@

    Returns: -the number of byte written or -1 in case of error. +the number of byte written or a negative xmlParserErrors code in case of error.

    @@ -1155,7 +1155,7 @@

    xmlParserInputBufferCreateFd ()

    xmlParserInputBufferPtr	xmlParserInputBufferCreateFd	(int fd, 
    xmlCharEncoding enc)
    -

    Create a buffered parser input for the progressive parsing for the input from a file descriptor

    +

    Create a buffered parser input for the progressive parsing for the input from a file descriptor The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on.

    @@ -1165,7 +1165,7 @@

    - + @@ -1180,7 +1180,7 @@

    xmlParserInputBufferCreateFile ()

    xmlParserInputBufferPtr	xmlParserInputBufferCreateFile	(FILE * file, 
    xmlCharEncoding enc)
    -

    Create a buffered parser input for the progressive parsing of a FILE * buffered C I/O

    +

    Create a buffered parser input for the progressive parsing of a FILE * buffered C I/O The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on.

    enc:the charset encoding if knownthe charset encoding if known (deprecated)
    Returns:
    @@ -1190,7 +1190,7 @@

    - + @@ -1205,7 +1205,7 @@

    xmlParserInputBufferCreateFilename ()

    xmlParserInputBufferPtr	xmlParserInputBufferCreateFilename	(const char * URI, 
    xmlCharEncoding enc)
    -

    Create a buffered parser input for the progressive parsing of a file If filename is "-' then we use stdin as the input. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. Do an encoding check if enc == XML_CHAR_ENCODING_NONE

    +

    Create a buffered parser input for the progressive parsing of a file Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. Do an encoding check if enc == XML_CHAR_ENCODING_NONE

    enc:the charset encoding if knownthe charset encoding if known (deprecated)
    Returns:
    @@ -1251,7 +1251,7 @@

    xmlParserInputBufferCreateIO ()

    xmlParserInputBufferPtr	xmlParserInputBufferCreateIO	(xmlInputReadCallback ioread, 
    xmlInputCloseCallback ioclose,
    void * ioctx,
    xmlCharEncoding enc)
    -

    Create a buffered parser input for the progressive parsing for the input from an I/O handler

    +

    Create a buffered parser input for the progressive parsing for the input from an I/O handler The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on.

    @@ -1269,7 +1269,7 @@

    - + @@ -1284,7 +1284,7 @@

    xmlParserInputBufferCreateMem ()

    xmlParserInputBufferPtr	xmlParserInputBufferCreateMem	(const char * mem, 
    int size,
    xmlCharEncoding enc)
    -

    Create a buffered parser input for the progressive parsing for the input from a memory area.

    +

    Create a parser input buffer for parsing from a memory area. This function makes a copy of the whole input buffer. If you are sure that the contents of the buffer will remain valid until the document was parsed, you can avoid the copy by using xmlParserInputBufferCreateStatic. The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on.

    enc:the charset encoding if knownthe charset encoding if known (deprecated)
    Returns:
    @@ -1298,11 +1298,11 @@

    - + - +
    enc:the charset encoding if knownthe charset encoding if known (deprecated)
    Returns:the new parser input or NULLthe new parser input or NULL in case of error.
    @@ -1313,7 +1313,7 @@

    xmlParserInputBufferCreateStatic ()

    xmlParserInputBufferPtr	xmlParserInputBufferCreateStatic	(const char * mem, 
    int size,
    xmlCharEncoding enc)
    -

    DEPRECATED: Use xmlParserInputBufferCreateMem.

    +

    Create a parser input buffer for parsing from a memory area. This functions assumes that the contents of the input buffer remain valid until the document was parsed. Use xmlParserInputBufferCreateMem otherwise. The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on.

    @@ -1331,7 +1331,7 @@

    - +
    Returns:the new parser input or NULLthe new parser input or NULL in case of error.
    @@ -1467,7 +1467,7 @@

    xmlRegisterHTTPPostCallbacks ()

    void	xmlRegisterHTTPPostCallbacks	(void)
    -

    By default, libxml submits HTTP output requests using the "PUT" method. Calling this method changes the HTTP output method to use the "POST" method instead.

    +

    DEPRECATED: Support for HTTP POST has been removed.


    diff --git a/doc/devhelp/libxml2-xmlerror.html b/doc/devhelp/libxml2-xmlerror.html index 678770f94..173f026c0 100644 --- a/doc/devhelp/libxml2-xmlerror.html +++ b/doc/devhelp/libxml2-xmlerror.html @@ -31,6 +31,7 @@

    Synopsis

    int xmlCopyError (const xmlError * from,
    xmlErrorPtr to); const xmlError * xmlCtxtGetLastError (void * ctx); void xmlCtxtResetLastError (void * ctx); +void xmlFormatError (const xmlError * err,
    xmlGenericErrorFunc channel,
    void * data); typedef void xmlGenericErrorFunc (void * ctx,
    const char * msg,
    ... ...); const xmlError * xmlGetLastError (void); void xmlParserError (void * ctx,
    const char * msg,
    ... ...); @@ -253,6 +254,11 @@

    XML_ERR_USER_STOP = 111 /* 111 */ XML_ERR_COMMENT_ABRUPTLY_ENDED = 112 /* 112 */ XML_WAR_ENCODING_MISMATCH = 113 /* 113 */ + XML_ERR_RESOURCE_LIMIT = 114 /* 114 */ + XML_ERR_ARGUMENT = 115 /* 115 */ + XML_ERR_SYSTEM = 116 /* 116 */ + XML_ERR_REDECL_PREDEF_ENTITY = 117 /* 117 */ + XML_ERR_INT_SUBSET_NOT_FINISHED = 118 /* 118 */ XML_NS_ERR_XML_NAMESPACE = 200 XML_NS_ERR_UNDEFINED_NAMESPACE = 201 /* 201 */ XML_NS_ERR_QNAME = 202 /* 202 */ @@ -515,6 +521,7 @@

    XML_IO_EADDRINUSE = 1554 /* 1554 */ XML_IO_EALREADY = 1555 /* 1555 */ XML_IO_EAFNOSUPPORT = 1556 /* 1556 */ + XML_IO_UNSUPPORTED_PROTOCOL = 1557 /* 1557 */ XML_XINCLUDE_RECURSION = 1600 XML_XINCLUDE_PARSE_VALUE = 1601 /* 1601 */ XML_XINCLUDE_ENTITY_DEF_MISMATCH = 1602 /* 1602 */ @@ -1005,6 +1012,31 @@


    +xmlFormatError ()

    +
    void	xmlFormatError			(const xmlError * err, 
    xmlGenericErrorFunc channel,
    void * data)
    +
    +

    Report a formatted error to a printf-like callback. This can result in a verbose multi-line report including additional information from the parser context. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + +
    err:the error
    channel:callback
    data:user data for callback
    +
    +
    +
    +

    xmlGetLastError ()

    const xmlError *	xmlGetLastError	(void)
    @@ -1048,7 +1080,7 @@

    xmlParserPrintFileContext ()

    void	xmlParserPrintFileContext	(xmlParserInputPtr input)
    -

    Displays current context within the input content for error tracking

    +

    DEPRECATED: Use xmlFormatError. Displays current context within the input content for error tracking

    @@ -1063,7 +1095,7 @@

    xmlParserPrintFileInfo ()

    void	xmlParserPrintFileInfo		(xmlParserInputPtr input)
    -

    Displays the associated file and line information for the current input

    +

    DEPRECATED: Use xmlFormatError. Displays the associated file and line information for the current input

    @@ -1176,7 +1208,7 @@

    xmlSetGenericErrorFunc ()

    void	xmlSetGenericErrorFunc		(void * ctx, 
    xmlGenericErrorFunc handler)
    -

    Function to reset the handler and the error context for out of context error messages. This simply means that @handler will be called for subsequent error messages while not parsing nor validating. And @ctx will be passed as first argument to @handler One can simply force messages to be emitted to another FILE * than stderr by setting @ctx to this file handle and @handler to NULL. For multi-threaded applications, this must be set separately for each thread.

    +

    DEPRECATED: See xmlSetStructuredErrorFunc for alternatives. Set the global "generic" handler and context for error messages. The generic error handler will only receive fragments of error messages which should be concatenated or printed to a stream. If handler is NULL, use the built-in default handler which prints to stderr. Since this is a global setting, it's a good idea to reset the error handler to its default value after collecting the errors you're interested in. For multi-threaded applications, this must be set separately for each thread.

    @@ -1197,7 +1229,7 @@

    xmlSetStructuredErrorFunc ()

    void	xmlSetStructuredErrorFunc	(void * ctx, 
    xmlStructuredErrorFunc handler)
    -

    Function to reset the handler and the error context for out of context structured error messages. This simply means that @handler will be called for subsequent error messages while not parsing nor validating. And @ctx will be passed as first argument to @handler For multi-threaded applications, this must be set separately for each thread.

    +

    DEPRECATED: Use a per-context error handler. It's recommended to use the per-context error handlers instead: - xmlCtxtSetErrorHandler (since 2.13.0) - xmlTextReaderSetStructuredErrorHandler - xmlXPathSetErrorHandler (since 2.13.0) - xmlXIncludeSetErrorHandler (since 2.13.0) - xmlSchemaSetParserStructuredErrors - xmlSchemaSetValidStructuredErrors - xmlRelaxNGSetParserStructuredErrors - xmlRelaxNGSetValidStructuredErrors Set the global "structured" handler and context for error messages. If handler is NULL, the error handler is deactivated. The structured error handler takes precedence over "generic" handlers, even per-context generic handlers. Since this is a global setting, it's a good idea to deactivate the error handler after collecting the errors you're interested in. For multi-threaded applications, this must be set separately for each thread.

    diff --git a/doc/devhelp/libxml2-xmlexports.html b/doc/devhelp/libxml2-xmlexports.html index 937d7cb90..05b5efea1 100644 --- a/doc/devhelp/libxml2-xmlexports.html +++ b/doc/devhelp/libxml2-xmlexports.html @@ -22,31 +22,12 @@

    xmlexports

    Author(s):

    Synopsis

    -
    #define XMLPUBFUN;
    -#define XMLPUBVAR;
    -
    +
    
     

    Description

    Details

    -
    -
    -

    -Macro XMLPUBFUN

    -
    #define XMLPUBFUN;
    -
    -

    Macro which declares an exportable function

    -
    -
    -
    -

    -Macro XMLPUBVAR

    -
    #define XMLPUBVAR;
    -
    -

    Macro which declares an exportable variable

    -
    -
    -
    +
    diff --git a/doc/devhelp/libxml2-xmlmemory.html b/doc/devhelp/libxml2-xmlmemory.html index 0a1198d52..57457aad2 100644 --- a/doc/devhelp/libxml2-xmlmemory.html +++ b/doc/devhelp/libxml2-xmlmemory.html @@ -267,7 +267,7 @@

    - +
    Returns:0.
    @@ -277,7 +277,7 @@

    xmlMallocAtomicLoc ()

    void *	xmlMallocAtomicLoc		(size_t size, 
    const char * file,
    int line)
    -

    a malloc() equivalent, with logging of the allocation info.

    +

    DEPRECATED: don't use

    @@ -306,7 +306,7 @@

    xmlMallocLoc ()

    void *	xmlMallocLoc			(size_t size, 
    const char * file,
    int line)
    -

    a malloc() equivalent, with logging of the allocation info.

    +

    DEPRECATED: don't use

    @@ -350,12 +350,12 @@

    xmlMemDisplay ()

    void	xmlMemDisplay			(FILE * fp)
    -

    show in-extenso the memory blocks allocated

    +

    DEPRECATED: This feature was removed.

    - +
    fp:a FILE descriptor used as the output file, if NULL, the result is written to the file .memorylista FILE descriptor
    @@ -365,13 +365,13 @@

    xmlMemDisplayLast ()

    void	xmlMemDisplayLast		(FILE * fp, 
    long nbBytes)
    -

    the last nbBytes of memory allocated and not freed, useful for dumping the memory left allocated between two places at runtime.

    +

    DEPRECATED: This feature was removed.

    - + @@ -513,13 +513,13 @@

    xmlMemShow ()

    void	xmlMemShow			(FILE * fp, 
    int nr)
    -

    show a show display of the memory allocated, and dump the @nr last allocated areas which were not freed

    +

    DEPRECATED: This feature was removed.

    fp:a FILE descriptor used as the output file, if NULL, the result is written to the file .memorylista FILE descriptor
    nbBytes:
    - + @@ -555,7 +555,7 @@

    xmlMemStrdupLoc ()

    char *	xmlMemStrdupLoc			(const char * str, 
    const char * file,
    int line)
    -

    a strdup() equivalent, with logging of the allocation info.

    +

    DEPRECATED: don't use

    fp:a FILE descriptor used as the output filea FILE descriptor
    nr:
    @@ -599,7 +599,7 @@

    xmlMemoryDump ()

    void	xmlMemoryDump			(void)
    -

    Dump in-extenso the memory blocks allocated to the file .memorylist

    +

    DEPRECATED: This feature was removed.


    @@ -628,7 +628,7 @@

    xmlReallocLoc ()

    void *	xmlReallocLoc			(void * ptr, 
    size_t size,
    const char * file,
    int line)
    -

    a realloc() equivalent, with logging of the allocation info.

    +

    DEPRECATED: don't use

    diff --git a/doc/devhelp/libxml2-xmlreader.html b/doc/devhelp/libxml2-xmlreader.html index 76b3a72a6..e3be72428 100644 --- a/doc/devhelp/libxml2-xmlreader.html +++ b/doc/devhelp/libxml2-xmlreader.html @@ -67,6 +67,7 @@

    Synopsis

    xmlChar * xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,
    int no); xmlChar * xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,
    const xmlChar * localName,
    const xmlChar * namespaceURI); void xmlTextReaderGetErrorHandler (xmlTextReaderPtr reader,
    xmlTextReaderErrorFunc * f,
    void ** arg); +const xmlError * xmlTextReaderGetLastError (xmlTextReaderPtr reader); int xmlTextReaderGetParserColumnNumber (xmlTextReaderPtr reader); int xmlTextReaderGetParserLineNumber (xmlTextReaderPtr reader); int xmlTextReaderGetParserProp (xmlTextReaderPtr reader,
    int prop); @@ -1218,6 +1219,27 @@


    +xmlTextReaderGetLastError ()

    +
    const xmlError *	xmlTextReaderGetLastError	(xmlTextReaderPtr reader)
    +
    +

    Available since 2.13.0.

    +

    ++ + + + + + + + + + +
    reader:an XML reader
    Returns:the last error.
    +
    +
    +
    +

    xmlTextReaderGetParserColumnNumber ()

    int	xmlTextReaderGetParserColumnNumber	(xmlTextReaderPtr reader)
    @@ -2142,7 +2164,7 @@

    xmlTextReaderSetErrorHandler ()

    void	xmlTextReaderSetErrorHandler	(xmlTextReaderPtr reader, 
    xmlTextReaderErrorFunc f,
    void * arg)
    -

    Register a callback function that will be called on error and warnings. If @f is NULL, the default error and warning handlers are restored.

    +

    DEPRECATED: Use xmlTextReaderSetStructuredErrorHandler. Register a callback function that will be called on error and warnings. If @f is NULL, the default error and warning handlers are restored.

    diff --git a/doc/devhelp/libxml2-xmlsave.html b/doc/devhelp/libxml2-xmlsave.html index 21262758b..083d0be42 100644 --- a/doc/devhelp/libxml2-xmlsave.html +++ b/doc/devhelp/libxml2-xmlsave.html @@ -27,6 +27,7 @@

    Synopsis

    typedef enum xmlSaveOption; int xmlSaveClose (xmlSaveCtxtPtr ctxt); long xmlSaveDoc (xmlSaveCtxtPtr ctxt,
    xmlDocPtr doc); +int xmlSaveFinish (xmlSaveCtxtPtr ctxt); int xmlSaveFlush (xmlSaveCtxtPtr ctxt); int xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt,
    xmlCharEncodingOutputFunc escape); int xmlSaveSetEscape (xmlSaveCtxtPtr ctxt,
    xmlCharEncodingOutputFunc escape); @@ -127,6 +128,27 @@


    +xmlSaveFinish ()

    +
    int	xmlSaveFinish			(xmlSaveCtxtPtr ctxt)
    +
    +

    Close a document saving context, i.e. make sure that all bytes have been output and free the associated data. Available since 2.13.0.

    +

    ++ + + + + + + + + + +
    ctxt:a document saving context
    Returns:an xmlParserErrors code.
    +
    +
    +
    +

    xmlSaveFlush ()

    int	xmlSaveFlush			(xmlSaveCtxtPtr ctxt)
    diff --git a/doc/devhelp/libxml2-xmlschemas.html b/doc/devhelp/libxml2-xmlschemas.html index 6fde79084..77f1cfc76 100644 --- a/doc/devhelp/libxml2-xmlschemas.html +++ b/doc/devhelp/libxml2-xmlschemas.html @@ -603,7 +603,7 @@

    xmlSchemaSetParserErrors ()

    void	xmlSchemaSetParserErrors	(xmlSchemaParserCtxtPtr ctxt, 
    xmlSchemaValidityErrorFunc err,
    xmlSchemaValidityWarningFunc warn,
    void * ctx)
    -

    Set the callback functions used to handle errors for a validation context

    +

    DEPRECATED: Use xmlSchemaSetParserStructuredErrors. Set the callback functions used to handle errors for a validation context

    @@ -657,7 +657,7 @@

    xmlSchemaSetValidErrors ()

    void	xmlSchemaSetValidErrors		(xmlSchemaValidCtxtPtr ctxt, 
    xmlSchemaValidityErrorFunc err,
    xmlSchemaValidityWarningFunc warn,
    void * ctx)
    -

    Set the error and warning callback information

    +

    DEPRECATED: Use xmlSchemaSetValidStructuredErrors. Set the error and warning callback information

    diff --git a/doc/devhelp/libxml2-xmlstring.html b/doc/devhelp/libxml2-xmlstring.html index c0ef99b5d..1476ed23f 100644 --- a/doc/devhelp/libxml2-xmlstring.html +++ b/doc/devhelp/libxml2-xmlstring.html @@ -841,7 +841,7 @@

    - +
    Returns:a pointer to a newly created string or NULL if any problema pointer to a newly created string or NULL if the start index is out of bounds or a memory allocation failed. If len is too large, the result is truncated.
    diff --git a/doc/devhelp/libxml2-xmlversion.html b/doc/devhelp/libxml2-xmlversion.html index b7fc9c4b3..73a0208af 100644 --- a/doc/devhelp/libxml2-xmlversion.html +++ b/doc/devhelp/libxml2-xmlversion.html @@ -22,14 +22,11 @@

    xmlversion

    Author(s): Daniel Veillard

    Synopsis

    -
    #define DEBUG_MEMORY_LOCATION;
    -#define LIBXML_AUTOMATA_ENABLED;
    +
    #define LIBXML_AUTOMATA_ENABLED;
     #define LIBXML_C14N_ENABLED;
     #define LIBXML_CATALOG_ENABLED;
     #define LIBXML_DEBUG_ENABLED;
    -#define LIBXML_DEBUG_RUNTIME;
     #define LIBXML_DOTTED_VERSION;
    -#define LIBXML_EXPR_ENABLED;
     #define LIBXML_FTP_ENABLED;
     #define LIBXML_HTML_ENABLED;
     #define LIBXML_HTTP_ENABLED;
    @@ -63,9 +60,6 @@ 

    Synopsis

    #define LIBXML_XPTR_ENABLED; #define LIBXML_XPTR_LOCS_ENABLED; #define LIBXML_ZLIB_ENABLED; -#define WITHOUT_TRIO; -#define WITH_TRIO; -void xmlCheckVersion (int version);

    Description

    @@ -74,14 +68,6 @@

    Details

    -Macro DEBUG_MEMORY_LOCATION

    -
    #define DEBUG_MEMORY_LOCATION;
    -
    -

    Whether the memory debugging is configured in

    -
    -
    -
    -

    Macro LIBXML_AUTOMATA_ENABLED

    #define LIBXML_AUTOMATA_ENABLED;
     
    @@ -114,14 +100,6 @@


    -Macro LIBXML_DEBUG_RUNTIME

    -
    #define LIBXML_DEBUG_RUNTIME;
    -
    -

    Removed

    -
    -
    -
    -

    Macro LIBXML_DOTTED_VERSION

    #define LIBXML_DOTTED_VERSION;
     
    @@ -130,14 +108,6 @@


    -Macro LIBXML_EXPR_ENABLED

    -
    #define LIBXML_EXPR_ENABLED;
    -
    -

    Whether the formal expressions interfaces are compiled in This code is unused and disabled unconditionally for now.

    -
    -
    -
    -

    Macro LIBXML_FTP_ENABLED

    #define LIBXML_FTP_ENABLED;
     
    @@ -400,37 +370,6 @@

    Whether the Zlib support is compiled in


    -
    -

    -Macro WITHOUT_TRIO

    -
    #define WITHOUT_TRIO;
    -
    -

    defined if the trio support should not be configured in

    -
    -
    -
    -

    -Macro WITH_TRIO

    -
    #define WITH_TRIO;
    -
    -

    defined if the trio support need to be configured in

    -
    -
    -
    -

    -xmlCheckVersion ()

    -
    void	xmlCheckVersion			(int version)
    -
    -

    check the compiled lib version against the include one. This can warn or immediately kill the application

    -
    -- - - - -
    version:the include version number
    -
    -

    diff --git a/doc/devhelp/libxml2-xmlwriter.html b/doc/devhelp/libxml2-xmlwriter.html index a274d09f6..833c99a7c 100644 --- a/doc/devhelp/libxml2-xmlwriter.html +++ b/doc/devhelp/libxml2-xmlwriter.html @@ -33,6 +33,7 @@

    Synopsis

    xmlTextWriterPtr xmlNewTextWriterMemory (xmlBufferPtr buf,
    int compression); xmlTextWriterPtr xmlNewTextWriterPushParser (xmlParserCtxtPtr ctxt,
    int compression); xmlTextWriterPtr xmlNewTextWriterTree (xmlDocPtr doc,
    xmlNodePtr node,
    int compression); +int xmlTextWriterClose (xmlTextWriterPtr writer); int xmlTextWriterEndAttribute (xmlTextWriterPtr writer); int xmlTextWriterEndCDATA (xmlTextWriterPtr writer); int xmlTextWriterEndComment (xmlTextWriterPtr writer); @@ -317,6 +318,28 @@


    +xmlTextWriterClose ()

    +
    int	xmlTextWriterClose		(xmlTextWriterPtr writer)
    +
    +

    Flushes and closes the output buffer. Available since 2.13.0.

    +
    ++ + + + + + + + + + +
    writer:the xmlTextWriterPtr +
    Returns:an xmlParserErrors code.
    +
    +
    +
    +

    xmlTextWriterEndAttribute ()

    int	xmlTextWriterEndAttribute	(xmlTextWriterPtr writer)
    diff --git a/doc/devhelp/libxml2-xpath.html b/doc/devhelp/libxml2-xpath.html index 59f965358..fcc427345 100644 --- a/doc/devhelp/libxml2-xpath.html +++ b/doc/devhelp/libxml2-xpath.html @@ -92,6 +92,7 @@

    Synopsis

    xmlXPathObjectPtr xmlXPathObjectCopy (xmlXPathObjectPtr val); long xmlXPathOrderDocElems (xmlDocPtr doc); int xmlXPathSetContextNode (xmlNodePtr node,
    xmlXPathContextPtr ctx); +void xmlXPathSetErrorHandler (xmlXPathContextPtr ctxt,
    xmlStructuredErrorFunc handler,
    void * data); typedef xmlXPathObjectPtr xmlXPathVariableLookupFunc (void * ctxt,
    const xmlChar * name,
    const xmlChar * ns_uri);

    @@ -1018,7 +1019,7 @@

    xmlXPathContextSetCache ()

    int	xmlXPathContextSetCache		(xmlXPathContextPtr ctxt, 
    int active,
    int value,
    int options)
    -

    Creates/frees an object cache on the XPath context. If activates XPath objects (xmlXPathObject) will be cached internally to be reused. @options: 0: This will set the XPath object caching: @value: This will set the maximum number of XPath objects to be cached per slot There are 5 slots for: node-set, string, number, boolean, and misc objects. Use <0 for the default number (100). Other values for @options have currently no effect.

    +

    Creates/frees an object cache on the XPath context. If activates XPath objects (xmlXPathObject) will be cached internally to be reused. @options: 0: This will set the XPath object caching: @value: This will set the maximum number of XPath objects to be cached per slot There are two slots for node-set and misc objects. Use <0 for the default number (100). Other values for @options have currently no effect.

    @@ -1472,6 +1473,31 @@


    +
    +

    +xmlXPathSetErrorHandler ()

    +
    void	xmlXPathSetErrorHandler		(xmlXPathContextPtr ctxt, 
    xmlStructuredErrorFunc handler,
    void * data)
    +
    +

    Register a callback function that will be called on errors and warnings. If handler is NULL, the error handler will be deactivated. Available since 2.13.0.

    +
    ++ + + + + + + + + + + + + + +
    ctxt:the XPath context
    handler:error handler
    data:user data which will be passed to the handler
    +
    +

    diff --git a/doc/devhelp/libxml2-xpathInternals.html b/doc/devhelp/libxml2-xpathInternals.html index 3a1f3ba72..079f9b5cc 100644 --- a/doc/devhelp/libxml2-xpathInternals.html +++ b/doc/devhelp/libxml2-xpathInternals.html @@ -67,7 +67,7 @@

    Synopsis

    xmlNodeSetPtr xmlXPathDistinctSorted (xmlNodeSetPtr nodes); void xmlXPathDivValues (xmlXPathParserContextPtr ctxt); int xmlXPathEqualValues (xmlXPathParserContextPtr ctxt); -void xmlXPathErr (xmlXPathParserContextPtr ctxt,
    int error); +void xmlXPathErr (xmlXPathParserContextPtr ctxt,
    int code); void xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); int xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,
    xmlXPathObjectPtr res); void xmlXPathFalseFunction (xmlXPathParserContextPtr ctxt,
    int nargs); @@ -961,7 +961,7 @@

    xmlXPathErr ()

    -
    void	xmlXPathErr			(xmlXPathParserContextPtr ctxt, 
    int error)
    +
    void	xmlXPathErr			(xmlXPathParserContextPtr ctxt, 
    int code)

    Handle an XPath error

    @@ -972,7 +972,7 @@

    - + @@ -2867,7 +2867,7 @@

    xmlXPathSubstringAfterFunction ()

    void	xmlXPathSubstringAfterFunction	(xmlXPathParserContextPtr ctxt, 
    int nargs)
    -

    Implement the substring-after() XPath function string substring-after(string, string) The substring-after function returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string, or the empty stringi if the first argument string does not contain the second argument string. For example, substring-after("1999/04/01","/") returns 04/01, and substring-after("1999/04/01","19") returns 99/04/01.

    +

    Implement the substring-after() XPath function string substring-after(string, string) The substring-after function returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string. For example, substring-after("1999/04/01","/") returns 04/01, and substring-after("1999/04/01","19") returns 99/04/01.

    a XPath parser context
    error:code: the error code
    diff --git a/doc/devhelp/libxml2.devhelp2 b/doc/devhelp/libxml2.devhelp2 index b32ce27b2..4076f9652 100644 --- a/doc/devhelp/libxml2.devhelp2 +++ b/doc/devhelp/libxml2.devhelp2 @@ -61,7 +61,6 @@ - @@ -93,9 +92,7 @@ - - @@ -130,8 +127,6 @@ - - @@ -142,14 +137,10 @@ - - - - @@ -242,7 +233,6 @@ - @@ -508,6 +498,7 @@ + @@ -556,6 +547,7 @@ + @@ -594,12 +586,15 @@ + + + @@ -731,6 +726,7 @@ + @@ -788,6 +784,7 @@ + @@ -1894,6 +1891,10 @@ + + + + @@ -1905,6 +1906,7 @@ + @@ -1942,6 +1944,7 @@ + @@ -2040,7 +2043,9 @@ + + @@ -2095,7 +2100,9 @@ + + @@ -2134,11 +2141,10 @@ - - + @@ -2177,7 +2183,9 @@ + + @@ -2186,7 +2194,9 @@ + + @@ -2270,6 +2280,7 @@ + @@ -2329,6 +2340,7 @@ + @@ -2340,10 +2352,14 @@ + + + + @@ -2376,7 +2392,7 @@ - + @@ -2436,6 +2452,7 @@ + @@ -2561,7 +2578,9 @@ + + @@ -2576,6 +2595,7 @@ + @@ -2650,6 +2670,7 @@ + @@ -2679,6 +2700,7 @@ + @@ -2813,6 +2835,7 @@ + @@ -2966,6 +2989,7 @@ + @@ -2992,6 +3016,7 @@ + @@ -3042,6 +3067,7 @@ + @@ -3346,6 +3372,7 @@ + @@ -3354,6 +3381,7 @@ + @@ -3489,6 +3517,7 @@ + diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml index 8b2e93794..6ed39fa82 100644 --- a/doc/libxml2-api.xml +++ b/doc/libxml2-api.xml @@ -40,12 +40,14 @@ + + @@ -401,7 +403,6 @@ - @@ -421,7 +422,9 @@ + + @@ -441,6 +444,7 @@ + @@ -463,9 +467,7 @@ Deprecated, don't use - - @@ -475,11 +477,15 @@ + + + + @@ -601,11 +607,8 @@ the core parser module Interfaces, constants and types related to the XML parser Daniel Veillard - - - @@ -642,6 +645,7 @@ + @@ -708,6 +712,10 @@ + + + + @@ -740,12 +748,14 @@ + + @@ -753,7 +763,9 @@ + + @@ -762,6 +774,7 @@ + @@ -873,6 +886,7 @@ + @@ -946,6 +960,7 @@ + @@ -965,6 +980,7 @@ + @@ -1563,6 +1579,7 @@ + @@ -1603,7 +1620,9 @@ + + @@ -1664,7 +1683,9 @@ + + @@ -1672,6 +1693,7 @@ + @@ -1701,6 +1723,7 @@ + @@ -1788,6 +1811,7 @@ + @@ -1796,6 +1820,7 @@ + @@ -2028,6 +2053,7 @@ + @@ -2076,6 +2102,7 @@ + @@ -2114,12 +2141,15 @@ + + + @@ -2238,6 +2268,7 @@ + @@ -2714,11 +2745,11 @@ - + @@ -2738,8 +2769,6 @@ macros for marking symbols as exportable/importable. macros for marking symbols as exportable/importable. - - interface for the memory allocator @@ -2871,6 +2900,7 @@ + @@ -2992,6 +3022,7 @@ + @@ -3332,14 +3363,11 @@ compile-time version information compile-time version information for the XML library Daniel Veillard - - - @@ -3373,9 +3401,6 @@ - - - text writing API for XML @@ -3392,6 +3417,7 @@ + @@ -3588,6 +3614,7 @@ + @@ -3805,9 +3832,6 @@ Macro to check that the value on top of the XPath stack is of a given type. Return(0) in case of failure - - Whether the memory debugging is configured in - Macro. A comment in a HTML document is really implemented the same way as a comment in an XML document. @@ -3920,15 +3944,9 @@ Whether Debugging module is configured in - - Removed - the version string like "1.2.3" - - Whether the formal expressions interfaces are compiled in This code is unused and disabled unconditionally for now. - Whether the FTP support is configured in @@ -4031,12 +4049,6 @@ macro used to provide portability of code to windows sockets - - defined if the trio support should not be configured in - - - defined if the trio support need to be configured in - Macro defining "fallback" @@ -4067,12 +4079,6 @@ Macro defining "xpointer" - - Macro which declares an exportable function - - - Macro which declares an exportable variable - Macro to do a casting from an object pointer to a function pointer without encountering a warning from gcc #define XML_CAST_FPTR(fptr) (*(void **)(&fptr)) This macro violated ISO C aliasing rules (gcc4 on s390 broke) so it is disabled now @@ -4083,15 +4089,9 @@ The specific XML Catalog Processing Instruction name. - - Bit in the loadsubset context field to tell to do complete the elements attributes lists with the ones defaulted from the DTDs. Use it to initialize xmlLoadExtDtdDefaultValue. - The default version of XML used: 1.0 - - Bit in the loadsubset context field to tell to do ID/REFs lookups. Use it to initialize xmlLoadExtDtdDefaultValue. - Macro to extract the content pointer of a node. @@ -4368,9 +4368,6 @@ If the wildcard is complete. - - Bit in the loadsubset context field to tell to not do ID/REFs registration. Used to initialize xmlLoadExtDtdDefaultValue in some special cases. - Both general and parameter entities need to be substituted. @@ -4715,7 +4712,7 @@ - + @@ -4790,8 +4787,9 @@ and not by parsing an instance'/> - + + @@ -4840,6 +4838,7 @@ and not by parsing an instance'/> + @@ -4878,12 +4877,15 @@ and not by parsing an instance'/> + + + @@ -5015,13 +5017,14 @@ and not by parsing an instance'/> + - + @@ -5055,7 +5058,7 @@ and not by parsing an instance'/> - + @@ -5074,6 +5077,7 @@ crash if you try to modify the tree)'/> + @@ -5723,7 +5727,7 @@ crash if you try to modify the tree)'/> - + @@ -5905,6 +5909,7 @@ if necessary or NULL'/> + @@ -6111,7 +6116,7 @@ set at the end of parsing'/> - + @@ -6258,13 +6263,13 @@ set at the end of parsing'/> - + - - - + + + @@ -6282,7 +6287,7 @@ set at the end of parsing'/> - + @@ -6292,7 +6297,7 @@ set at the end of parsing'/> - + @@ -6322,7 +6327,7 @@ set at the end of parsing'/> - + @@ -6336,17 +6341,19 @@ set at the end of parsing'/> + + - + - + @@ -6355,7 +6362,7 @@ set at the end of parsing'/> - + @@ -6880,6 +6887,18 @@ Could we use @subtypes for this?'/> + + DEPRECATED: This handler is unused and will be removed from future versions. Default old SAX v1 handler for HTML, builds the DOM tree + + + Global setting, DEPRECATED. + + + DEPRECATED: This handler is unused and will be removed from future versions. Default SAX version1 handler for XML, builds the DOM tree + + + DEPRECATED: Don't use The default SAX Locator { getPublicId, getSystemId, getLineNumber, getColumnNumber} + @mem: an already allocated block of memory The variable holding the libxml free() implementation @@ -6899,7 +6918,10 @@ Could we use @subtypes for this?'/> @str: a zero terminated string The variable holding the libxml strdup() implementation Returns the copy of the string or NULL in case of error - + + DEPRECATED: Don't use Global setting, asking the parser to print out debugging information. while handling entities. Disabled by default + + arbitrary depth limit for the XML documents that we allow to process. This is not a limitation of the parser but a safety boundary feature. It can be disabled with the XML_PARSE_HUGE parser option. @@ -7250,61 +7272,68 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTML_ENABLED) - Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. - + DEPRECATED: Use htmlNewParserCtxt and htmlCtxtReadFile. Create a parser context to read from a file. A non-NULL encoding overrides encoding declarations in the document. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. + - + defined(LIBXML_HTML_ENABLED) - Create a parser context for an HTML in-memory document. + DEPRECATED: Use htmlNewParserCtxt and htmlCtxtReadMemory. Create a parser context for an HTML in-memory document. The input buffer must not contain any terminating null bytes. defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED) - Create a parser context for using the HTML parser in push mode The value of @filename is used for fetching external entities and error/warning reports. - - - - + Create a parser context for using the HTML parser in push mode. + + + + - - + + + + + defined(LIBXML_HTML_ENABLED) + Parse an HTML document and return the resulting document tree. Available since 2.13.0. + + + defined(LIBXML_HTML_ENABLED) - parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context + Parse an HTML in-memory document and build a tree. See htmlCtxtUseOptions for details. - - - + + + defined(LIBXML_HTML_ENABLED) - parse an XML from a file descriptor and build a tree. This reuses the existing @ctxt parser context + Parse an HTML from a file descriptor and build a tree. See htmlCtxtUseOptions for details. NOTE that the file descriptor will not be closed when the context is freed or reset. - - - + + + defined(LIBXML_HTML_ENABLED) - parse an XML file from the filesystem or the network. This reuses the existing @ctxt parser context + Parse an HTML file from the filesystem, the network or a user-defined resource loader. See xmlNewInputURL and htmlCtxtUseOptions for details. - - + + defined(LIBXML_HTML_ENABLED) - parse an HTML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context + Parse an HTML document from I/O functions and source and build a tree. See xmlNewInputIO and htmlCtxtUseOptions for details. @@ -7316,14 +7345,14 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTML_ENABLED) - parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context + Parse an HTML in-memory document and build a tree. The input buffer must not contain any terminating null bytes. See htmlCtxtUseOptions for details. - - - + + + defined(LIBXML_HTML_ENABLED) @@ -7434,7 +7463,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTML_ENABLED) - Set and return the previous value for handling HTML omitted tags. + DEPRECATED: Use HTML_PARSE_NOIMPLIED Set and return the previous value for handling HTML omitted tags. @@ -7478,12 +7507,12 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTML_ENABLED) - Allocate and initialize a new parser context. + Allocate and initialize a new HTML parser context. This can be used to parse HTML documents into DOM trees with functions like xmlCtxtReadFile or xmlCtxtReadMemory. See htmlCtxtUseOptions for parser options. See xmlCtxtSetErrorHandler for advanced error handling. See xmlNewInputURL, xmlNewInputMemory, xmlNewInputIO and similar functions for advanced input control. See htmlNewSAXParserCtxt for custom SAX parsers. defined(LIBXML_HTML_ENABLED) - Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data. + Allocate and initialize a new HTML SAX parser context. If userData is NULL, the parser context will be passed as user data. Available since 2.11.0. If you want support older versions, it's best to invoke htmlNewParserCtxt and set ctxt->sax with struct assignment. Also see htmlNewParserCtxt. @@ -7548,24 +7577,24 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED) - Parse a Chunk of memory - + Parse a chunk of memory in push parser mode. Assumes that the parser context was initialized with htmlCreatePushParserCtxt. The last chunk, which will often be empty, must be marked with the @terminate flag. With the default SAX callbacks, the resulting document will be available in ctxt->myDoc. This pointer will not be freed by the library. If the document isn't well-formed, ctxt->myDoc is set to NULL. + - - + + defined(LIBXML_HTML_ENABLED) - parse an HTML in-memory document and build a tree. + DEPRECATED: Use htmlReadDoc. Parse an HTML in-memory document and build a tree. This function uses deprecated global parser options. - + defined(LIBXML_HTML_ENABLED) - parse an HTML document (and build a tree if using the standard SAX interface). - + Parse an HTML document and invoke the SAX handlers. This is useful if you're only interested in custom SAX callbacks. If you want a document tree, use htmlCtxtParseDocument. + @@ -7583,55 +7612,55 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTML_ENABLED) - parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. + Parse an HTML file and build a tree. See xmlNewInputURL for details. - + defined(LIBXML_HTML_ENABLED) - parse an XML in-memory document and build a tree. - - - - - + Convenience function to parse an HTML document from a zero-terminated string. See htmlCtxtReadDoc for details. + + + + + defined(LIBXML_HTML_ENABLED) - parse an HTML from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the reader is closed or reset. + Convenience function to parse an HTML document from a file descriptor. NOTE that the file descriptor will not be closed when the context is freed or reset. See htmlCtxtReadFd for details. - + - + defined(LIBXML_HTML_ENABLED) - parse an XML file from the filesystem or the network. - + Convenience function to parse an HTML file from the filesystem, the network or a global user-defined resource loader. See htmlCtxtReadFile for details. + - - + + defined(LIBXML_HTML_ENABLED) - parse an HTML document from I/O functions and source and build a tree. + Convenience function to parse an HTML document from I/O functions and context. See htmlCtxtReadIO for details. - + - - + + defined(LIBXML_HTML_ENABLED) - parse an XML in-memory document and build a tree. + Convenience function to parse an HTML document from memory. The input buffer must not contain any terminating null bytes. See htmlCtxtReadMemory for details. - + @@ -7649,7 +7678,7 @@ Could we use @subtypes for this?'/> DEPRECATED: Use htmlNewSAXParserCtxt and htmlCtxtReadFile. parse an HTML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines. - + @@ -8101,13 +8130,13 @@ Could we use @subtypes for this?'/> - Add a new node to @parent, at the end of the child (or property) list merging adjacent TEXT nodes (in which case @cur is freed) If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed. All tree manipulation functions can safely move nodes within a document. But when moving nodes from one document to another, references to namespaces in element or attribute nodes are NOT fixed. In this case, you MUST call xmlReconciliateNs after the move operation to avoid memory errors. - + Unlink @cur and append it to the children of @parent. If @cur is a text node, it may be merged with an adjacent text node and freed. In this case the text node containing the merged content is returned. If @cur is an attribute node, it is appended to the attributes of @parent. If the attribute list contains an attribute with a name matching @elem, the old attribute is destroyed. General notes: Move operations like xmlAddChild can cause element or attribute nodes to reference namespaces that aren't declared in one of their ancestors. This can lead to use-after-free errors if the elements containing the declarations are freed later, especially when moving nodes from one document to another. You should consider calling xmlReconciliateNs after a move operation to normalize namespaces. Another option is to call xmlDOMWrapAdoptNode with the target parent before moving a node. For the most part, move operations don't check whether the resulting tree structure is valid. Users must make sure that parent nodes only receive children of valid types. Inserted child nodes must never be an ancestor of the parent node to avoid cycles in the tree structure. In general, only document, document fragments, elements and attributes should be used as parent nodes. When moving a node between documents and a memory allocation fails, the node's content will be corrupted and it will be unlinked. In this case, the node must be freed manually. Moving DTDs between documents isn't supported. + - Add a list of node at the end of the child list of the parent merging adjacent TEXT nodes (@cur may be freed) See the note regarding namespaces in xmlAddChild. + Append a node list to another node. See xmlAddChild. @@ -8147,6 +8176,18 @@ Could we use @subtypes for this?'/> + + Register a new entity for this document. Available since 2.13.0. + + + + + + + + + + Register a new id declaration @@ -8155,11 +8196,17 @@ Could we use @subtypes for this?'/> + + Register a new id declaration Available since 2.13.0. + + + + - Add a new node @elem as the next sibling of @cur If the new node was already inserted in a document it is first unlinked from its existing context. As a result of text merging @elem may be freed. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed. See the note regarding namespaces in xmlAddChild. - - - + Unlinks @cur and inserts it as next sibling after @prev. Unlike xmlAddChild this function does not merge text nodes. If @cur is an attribute node, it is inserted after attribute @prev. If the attribute list contains an attribute with a name matching @cur, the old attribute is destroyed. See the notes in xmlAddChild. + + + Register a new notation declaration @@ -8172,10 +8219,10 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) - Add a new node @elem as the previous sibling of @cur merging adjacent TEXT nodes (@elem may be freed) If the new node was already inserted in a document it is first unlinked from its existing context. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed. See the note regarding namespaces in xmlAddChild. - - - + Unlinks @cur and inserts it as previous sibling before @next. Unlike xmlAddChild this function does not merge text nodes. If @cur is an attribute node, it is inserted before attribute @next. If the attribute list contains an attribute with a name matching @cur, the old attribute is destroyed. See the notes in xmlAddChild. + + + DEPRECATED, do not use. This function will be removed from the public API. Register a new ref declaration @@ -8186,10 +8233,10 @@ Could we use @subtypes for this?'/> - Add a new element @elem to the list of siblings of @cur merging adjacent TEXT nodes (@elem may be freed) If the new element was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in xmlAddChild. - - - + Unlinks @cur and inserts it as last sibling of @node. If @cur is a text node, it may be merged with an adjacent text node and freed. In this case the text node containing the merged content is returned. If @cur is an attribute node, it is appended to the attribute list containing @node. If the attribute list contains an attribute with a name matching @cur, the old attribute is destroyed. See the notes in xmlAddChild. + + + defined(LIBXML_OUTPUT_ENABLED) @@ -8198,9 +8245,9 @@ Could we use @subtypes for this?'/> - Create a buffered parser input for progressive parsing + Create a buffered parser input for progressive parsing. The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on. - + defined(LIBXML_OUTPUT_ENABLED) @@ -8533,17 +8580,31 @@ Could we use @subtypes for this?'/> - Expresses the URI of the reference in terms relative to the base. Some examples of this operation include: base = "http://site1.com/docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif Note: if the URI reference is really weird or complicated, it may be worthwhile to first convert it into a "nice" one by calling xmlBuildURI (using 'base') before calling this routine, since this routine (for reasonable efficiency) assumes URI has already been through some validation. + See xmlBuildRelativeURISafe. + + Expresses the URI of the reference in terms relative to the base. Some examples of this operation include: base = "http://site1.com/docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif Note: if the URI reference is really weird or complicated, it may be worthwhile to first convert it into a "nice" one by calling xmlBuildURI (using 'base') before calling this routine, since this routine (for reasonable efficiency) assumes URI has already been through some validation. Available since 2.13.0. + + + + + Computes he final URI of the reference done by checking that the given URI is valid, and building the final URI using the base URI. This is processed according to section 5.2 of the RFC 2396 5.2. Resolving Relative References to Absolute Form + + Computes he final URI of the reference done by checking that the given URI is valid, and building the final URI using the base URI. This is processed according to section 5.2 of the RFC 2396 5.2. Resolving Relative References to Absolute Form Available since 2.13.0. + + + + + This function provides the current index of the parser relative to the start of the current entity. This function is computed in bytes from the beginning starting at zero and finishing at the size in byte of the file if parsing a file. The function is of constant cost if the input is UTF-8 but can be costly if run on non-UTF-8 input. @@ -8604,8 +8665,8 @@ Could we use @subtypes for this?'/> - Constructs a canonic path from the specified path. - + Prepares a path. If the path contains the substring "://", it is considered a Legacy Extended IRI. Characters which aren't allowed in URIs are escaped. Otherwise, the path is considered a filesystem path which is copied without modification. The caller is responsible for freeing the memory occupied by the returned string. If there is insufficient memory available, or the argument is NULL, the function returns NULL. + @@ -8792,12 +8853,12 @@ Could we use @subtypes for this?'/> - function checks to see if @path is a valid source (file, socket...) for XML. if stat is not available on the target machine, + DEPRECATED: Internal function, don't use. if stat is not available on the target machine, - - Check an input in case it was created from an HTTP stream, in that case it will handle encoding and update of the base URL in case of redirection. It also checks for HTTP errors in which case the input is cleanly freed up and an appropriate error is raised in context + + DEPRECATED: Internal function, don't use. Check an input in case it was created from an HTTP stream, in that case it will handle encoding and update of the base URL in case of redirection. It also checks for HTTP errors in which case the input is cleanly freed up and an appropriate error is raised in context @@ -8816,15 +8877,10 @@ Could we use @subtypes for this?'/> - - check the compiled lib version against the include one. This can warn or immediately kill the application - - - defined(LIBXML_TREE_ENABLED) - Finds the current number of child nodes of that element which are element nodes. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. - + Count the number of child nodes which are elements. Note that entity references are not expanded. + @@ -8835,7 +8891,7 @@ Could we use @subtypes for this?'/> Unregisters all aliases - + DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all. @@ -8902,8 +8958,8 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) - Do a copy of the document info. If recursive, the content tree will be copied too as well as DTD, namespaces and entities. - + Copy a document. If recursive, the content tree will be copied too as well as DTD, namespaces and entities. + @@ -8915,9 +8971,9 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) - Do a copy of the dtd. - - + Copy a DTD. + + Build a copy of an element content description. Deprecated, use xmlCopyDocElementContent instead @@ -8949,24 +9005,24 @@ Could we use @subtypes for this?'/> - Do a copy of the namespace. - + Copy a namespace. + - Do a copy of an namespace list. - + Copy a namespace list. + - Do a copy of the node. - + Copy a node. Use of this function is DISCOURAGED in favor of xmlDocCopyNode. + - Do a recursive copy of the node list. Use xmlDocCopyNodeList() if possible to ensure string interning. - + Copy a node list and all children. Use of this function is DISCOURAGED in favor of xmlDocCopyNodeList. + @@ -8976,14 +9032,14 @@ Could we use @subtypes for this?'/> - Do a copy of the attribute. - + Create a copy of the attribute. This function sets the parent pointer of the copy to @target but doesn't set the attribute on the target element. Users should consider to set the attribute by calling xmlAddChild afterwards or reset the parent pointer to NULL. + - Do a copy of an attribute list. - + Create a copy of an attribute list. This function sets the parent pointers of the copied attributes to @target but doesn't set the attributes on the target element. + @@ -8997,7 +9053,7 @@ Could we use @subtypes for this?'/> - Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. + DEPRECATED: Use xmlNewInputURL. Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. @@ -9009,87 +9065,98 @@ Could we use @subtypes for this?'/> - Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. + DEPRECATED: Use xmlNewParserCtxt and xmlCtxtReadFile. Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. Create a parser context for using the XML parser with an existing I/O stream - - + + - + - + - Create the internal subset of a document - - - - - + Create a DTD node. If a document is provided and it already has an internal subset, the existing DTD object is returned without creating a new object. If the document has no internal subset, it will be set to the created DTD. + + + + + - Create a parser context for an XML in-memory document. + Create a parser context for an XML in-memory document. The input buffer must not contain a terminating null byte. defined(LIBXML_PUSH_ENABLED) - Create a parser context for using the XML parser in push mode. If @buffer and @size are non-NULL, the data is used to detect the encoding. The remaining characters will be parsed so they don't need to be fed in again through xmlParseChunk. To allow content encoding detection, @size should be >= 4 The value of @filename is used for fetching external entities and error/warning reports. - - - - - - + Create a parser context for using the XML parser in push mode. See xmlParseChunk. Passing an initial chunk is useless and deprecated. @filename is used as base URI to fetch external entities and for error reports. + + + + + + Simply creates an empty xmlURI - Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses + DEPRECATED: Use xmlNewParserCtxt and xmlCtxtReadFile. Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses + + Handle an out-of-memory error. Available since 2.13.0. + + + Get the last parsing error registered. + + Parse an XML document and return the resulting document tree. Takes ownership of the input object. Available since 2.13.0. + + + + - parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context + Parse an XML in-memory document and build a tree. @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details. - - + + - parse an XML from a file descriptor and build a tree. This reuses the existing @ctxt parser context NOTE that the file descriptor will not be closed when the reader is closed or reset. + Parse an XML document from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the context is freed or reset. @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details. - - + + - parse an XML file from the filesystem or the network. This reuses the existing @ctxt parser context + Parse an XML file from the filesystem, the network or a user-defined resource loader. See xmlNewInputURL and xmlCtxtUseOptions for details. - + - parse an XML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context + parse an XML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details. @@ -9100,13 +9167,13 @@ Could we use @subtypes for this?'/> - parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context + Parse an XML in-memory document and build a tree. The input buffer must not contain a terminating null byte. @URL is used as base to resolve external entities and for error reporting. See xmlCtxtUseOptions for details. - - + + @@ -9128,14 +9195,27 @@ Could we use @subtypes for this?'/> + + Register a callback function that will be called on errors and warnings. If handler is NULL, the error handler will be deactivated. This is the recommended way to collect errors from the parser and takes precedence over all other error reporting mechanisms. These are (in order of precedence): - per-context structured handler (xmlCtxtSetErrorHandler) - per-context structured "serror" SAX handler - global structured handler (xmlSetStructuredErrorFunc) - per-context generic "error" and "warning" SAX handlers - global generic handler (xmlSetGenericErrorFunc) - print to stderr Available since 2.13.0. + + + + + To protect against exponential entity expansion ("billion laughs"), the size of serialized output is (roughly) limited to the input size multiplied by this factor. The default value is 5. When working with documents making heavy use of entity expansion, it can be necessary to increase the value. For security reasons, this should only be considered when processing trusted input. + + Applies the options to the parser context. Unset options are cleared. Available since 2.13.0. With older versions, you can use xmlCtxtUseOptions. XML_PARSE_RECOVER Enable "recovery" mode which allows non-wellformed documents. How this mode behaves exactly is unspecified and may change without further notice. Use of this feature is DISCOURAGED. XML_PARSE_NOENT Despite the confusing name, this option enables substitution of entities. The resulting tree won't contain any entity reference nodes. This option also enables loading of external entities (both general and parameter entities) which is dangerous. If you process untrusted data, it's recommended to set the XML_PARSE_NO_XXE option to disable loading of external entities. XML_PARSE_DTDLOAD Enables loading of an external DTD and the loading and substitution of external parameter entities. Has no effect if XML_PARSE_NO_XXE is set. XML_PARSE_DTDATTR Adds default attributes from the DTD to the result document. Implies XML_PARSE_DTDLOAD, but loading of external content can be disabled with XML_PARSE_NO_XXE. XML_PARSE_DTDVALID This option enables DTD validation which requires to load external DTDs and external entities (both general and parameter entities) unless XML_PARSE_NO_XXE was set. XML_PARSE_NO_XXE Disables loading of external DTDs or entities. XML_PARSE_NOERROR Disable error and warning reports to the error handlers. Errors are still accessible with xmlCtxtGetLastError. XML_PARSE_NOWARNING Disable warning reports. XML_PARSE_PEDANTIC Enable some pedantic warnings. XML_PARSE_NOBLANKS Remove some text nodes containing only whitespace from the result document. Which nodes are removed depends on DTD element declarations or a conservative heuristic. The reindenting feature of the serialization code relies on this option to be set when parsing. Use of this option is DISCOURAGED. XML_PARSE_SAX1 Always invoke the deprecated SAX1 startElement and endElement handlers. This option is DEPRECATED. XML_PARSE_NONET Disable network access with the builtin HTTP and FTP clients. XML_PARSE_NODICT Create a document without interned strings, making all strings separate memory allocations. XML_PARSE_NSCLEAN Remove redundant namespace declarations from the result document. XML_PARSE_NOCDATA Output normal text nodes instead of CDATA nodes. XML_PARSE_COMPACT Store small strings directly in the node struct to save memory. XML_PARSE_OLD10 Use old Name productions from before XML 1.0 Fifth Edition. This options is DEPRECATED. XML_PARSE_HUGE Relax some internal limits. Maximum size of text nodes, tags, comments, processing instructions, CDATA sections, entity values normal: 10M huge: 1B Maximum size of names, system literals, pubid literals normal: 50K huge: 10M Maximum nesting depth of elements normal: 256 huge: 2048 Maximum nesting depth of entities normal: 20 huge: 40 XML_PARSE_OLDSAX Enable an unspecified legacy mode for SAX parsers. This option is DEPRECATED. XML_PARSE_IGNORE_ENC Ignore the encoding in the XML declaration. This option is mostly unneeded these days. The only effect is to enforce UTF-8 decoding of ASCII-like data. XML_PARSE_BIG_LINES Enable reporting of line numbers larger than 65535. + + + + - Applies the options to the parser context + DEPRECATED: Use xmlCtxtSetOptions. Applies the options to the parser context. The following options are never cleared and can only be enabled: XML_PARSE_NOERROR XML_PARSE_NOWARNING XML_PARSE_NONET XML_PARSE_NSCLEAN XML_PARSE_NOCDATA XML_PARSE_COMPACT XML_PARSE_OLD10 XML_PARSE_HUGE XML_PARSE_OLDSAX XML_PARSE_IGNORE_ENC XML_PARSE_BIG_LINES @@ -9303,7 +9383,7 @@ Could we use @subtypes for this?'/> - Registers a callback for node destruction + DEPRECATED: don't use Registers a callback for node destruction @@ -9385,15 +9465,15 @@ Could we use @subtypes for this?'/> - Do a copy of the node to a given document. - + Copy a node into another document. + - Do a recursive copy of the node list. - + Copy a node list and all children into a new document. + @@ -9450,40 +9530,40 @@ Could we use @subtypes for this?'/> Get the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...). - + defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) - Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...). - + Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...). @root must be an element node. It is unlinked before insertion. + defined(LIBXML_OUTPUT_ENABLED) - This will dump the content of the attribute declaration as an XML DTD definition + DEPRECATED: Use xmlSaveTree. This will dump the content of the attribute declaration as an XML DTD definition defined(LIBXML_OUTPUT_ENABLED) - This will dump the content of the attribute table as an XML DTD definition + DEPRECATED: Don't use. This will dump the content of the attribute table as an XML DTD definition defined(LIBXML_OUTPUT_ENABLED) - This will dump the content of the element declaration as an XML DTD definition + DEPRECATED: Use xmlSaveTree. This will dump the content of the element declaration as an XML DTD definition defined(LIBXML_OUTPUT_ENABLED) - This will dump the content of the element table as an XML DTD definition + DEPRECATED: Don't use. This will dump the content of the element table as an XML DTD definition @@ -9504,14 +9584,14 @@ Could we use @subtypes for this?'/> defined(LIBXML_OUTPUT_ENABLED) - This will dump the content the notation declaration as an XML DTD definition + DEPRECATED: Don't use. This will dump the content the notation declaration as an XML DTD definition defined(LIBXML_OUTPUT_ENABLED) - This will dump the content of the notation table as an XML DTD definition + DEPRECATED: Don't use. This will dump the content of the notation table as an XML DTD definition @@ -9699,38 +9779,45 @@ Could we use @subtypes for this?'/> - Close an I/O channel - + DEPRECATED: Internal function, don't use. + - input from FILE * + DEPRECATED: Internal function, don't use. - Wrapper around xmlFileOpen_real that try it with an unescaped version of @filename, if this fails fallback to @filename - + DEPRECATED: Internal function, don't use. + - Read @len bytes to @buffer from the I/O channel. - + DEPRECATED: Internal function, don't use. + - Search in the registered set the handler able to read/write that encoding or create a new one. - + DEPRECATED: Use xmlOpenCharEncodingHandler which has better error reporting. + defined(LIBXML_TREE_ENABLED) - Finds the first child node of that element which is a Element node Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. - + Find the first child node which is an element. Note that entity references are not expanded. + + + Report a formatted error to a printf-like callback. This can result in a verbose multi-line report including additional information from the parser context. Available since 2.13.0. + + + + + Deallocate the memory used by an entities hash table. @@ -9749,7 +9836,7 @@ Could we use @subtypes for this?'/> - Free up all the structures used by a document, tree included. + Free a document including all children and associated DTDs. @@ -9780,9 +9867,9 @@ Could we use @subtypes for this?'/> - + Frees the entity. - + free an enumeration attribute node (recursive). @@ -9810,12 +9897,12 @@ Could we use @subtypes for this?'/> - Free a node, this is a recursive behaviour, all the children are freed too. This doesn't unlink the child from the list, use xmlUnlinkNode() first. + Free a node including all the children. This doesn't unlink the node from the tree. Call xmlUnlinkNode first unless @cur is a root node. - Free a node and all its siblings, this is a recursive behaviour, all the children are freed too. + Free a node list including all children. @@ -9825,12 +9912,12 @@ Could we use @subtypes for this?'/> - Free up the structures associated to a namespace + Free an xmlNs object. - Free up all the structures associated to the chained namespaces. + Free a list of xmlNs objects. @@ -9857,14 +9944,14 @@ Could we use @subtypes for this?'/> - Free one attribute, all the content is freed too + Free an attribute including all children. - Free a property and all its siblings, all the children are freed too. + Free an attribute list including all children. - + xmlRFreeMutex() is used to reclaim resources associated with a reentrant mutex. @@ -9935,8 +10022,8 @@ Could we use @subtypes for this?'/> - Search in the registered set the handler able to read/write that encoding. - + DEPRECATED: Use xmlLookupCharEncodingHandler which has better error reporting. + @@ -9945,7 +10032,7 @@ Could we use @subtypes for this?'/> - get the default compression mode used, ZLIB based. + DEPRECATED: Use xmlGetDocCompressMode get the default compression mode used, ZLIB based. @@ -9967,7 +10054,7 @@ Could we use @subtypes for this?'/> - Search the DTD for the description of this element + Search the DTD for the description of this element NOTE: A NULL return value can also mean that a memory allocation failed. @@ -10004,7 +10091,7 @@ Could we use @subtypes for this?'/> - + Get the default external entity resolver function for the application @@ -10034,13 +10121,13 @@ Could we use @subtypes for this?'/> - Get the internal subset of a document - + Get the internal subset of a document. + - Search the last child of a node. - + Find the last child of a node. + @@ -10053,8 +10140,8 @@ Could we use @subtypes for this?'/> - Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. This function is similar to xmlGetProp except it will accept only an attribute in no namespace. - + Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. This function is similar to xmlGetProp except it will accept only an attribute in no namespace. NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue. + @@ -10066,14 +10153,22 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) - Search all the namespace applying to a given element. - + Find all in-scope namespaces of a node. Use xmlGetNsListSafe for better error reporting. + + + + + + defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) + Find all in-scope namespaces of a node. @out returns a NULL terminated array of namespace pointers that must be freed by the caller. Available since 2.13.0. + + - Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. - + Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue. + @@ -10090,8 +10185,8 @@ Could we use @subtypes for this?'/> - Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. NOTE: this function acts independently of namespaces associated to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() for namespace aware processing. - + Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. NOTE: This function acts independently of namespaces associated to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() for namespace aware processing. NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue. + @@ -10124,20 +10219,44 @@ Could we use @subtypes for this?'/> - Search for an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. Note that a namespace of NULL indicates to use the default namespace. - + Search for an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values. Note that a namespace of NULL indicates to use the default namespace. + - Search an attribute associated to a node This function also looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. - + Search an attribute associated to a node This function also looks in DTD attribute declaration for #FIXED or default declaration values. + + + Add a hash table entry. If an entry with this key already exists, payload will not be updated and 0 is returned. This return value can't be distinguished from out-of-memory errors, so this function should be used with care. Available since 2.13.0. + + + + + + + Add a hash table entry with two strings as key. See xmlHashAdd. Available since 2.13.0. + + + + + + + + Add a hash table entry with three strings as key. See xmlHashAdd. Available since 2.13.0. + + + + + + + - Add a hash table entry. If an entry with this key already exists, payload will not be updated and -1 is returned. This return value can't be distinguished from out-of-memory errors, so this function should be used with care. + Add a hash table entry. If an entry with this key already exists, payload will not be updated and -1 is returned. This return value can't be distinguished from out-of-memory errors, so this function should be used with care. NOTE: This function doesn't allow to distinguish malloc failures from existing entries. Use xmlHashAdd instead. @@ -10167,11 +10286,18 @@ Could we use @subtypes for this?'/> - Copy the hash @table using @copy to copy payloads. + DEPRECATED: Leaks memory in error case. Copy the hash table using @copy to copy payloads. + + Copy the hash table using @copyFunc to copy payloads. Available since 2.13.0. + + + + + Create a new hash table. Set size to zero if the number of entries can't be estimated. @@ -10357,25 +10483,25 @@ Could we use @subtypes for this?'/> defined(LIBXML_FTP_ENABLED) - Close an FTP I/O channel + DEPRECATED: Internal function, don't use. Close an FTP I/O channel defined(LIBXML_FTP_ENABLED) - check if the URI matches an FTP one + DEPRECATED: Internal function, don't use. check if the URI matches an FTP one defined(LIBXML_FTP_ENABLED) - open an FTP I/O channel + DEPRECATED: Internal function, don't use. open an FTP I/O channel defined(LIBXML_FTP_ENABLED) - Read @len bytes to @buffer from the I/O channel. + DEPRECATED: Internal function, don't use. Read @len bytes to @buffer from the I/O channel. @@ -10383,32 +10509,32 @@ Could we use @subtypes for this?'/> defined(LIBXML_HTTP_ENABLED) - Close an HTTP I/O channel + DEPRECATED: Internal function, don't use. Close an HTTP I/O channel defined(LIBXML_HTTP_ENABLED) - check if the URI matches an HTTP one + DEPRECATED: Internal function, don't use. check if the URI matches an HTTP one defined(LIBXML_HTTP_ENABLED) - open an HTTP I/O channel + DEPRECATED: Internal function, don't use. open an HTTP I/O channel defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) - Open a temporary buffer to collect the document for a subsequent HTTP POST request. Non-static as is called from the output buffer creation routine. - + DEPRECATED: Support for HTTP POST has been removed. + defined(LIBXML_HTTP_ENABLED) - Read @len bytes to @buffer from the I/O channel. + DEPRECATED: Internal function, don't use. Read @len bytes to @buffer from the I/O channel. @@ -10426,13 +10552,13 @@ Could we use @subtypes for this?'/> DEPRECATED: Alias for xmlInitParser. - + DEPRECATED: Alias for xmlInitParser. DEPRECATED: Alias for xmlInitParser. - + DEPRECATED: Don't use. -- Initialize (set to initial state) node info sequence @@ -10530,7 +10656,7 @@ Could we use @subtypes for this?'/> Determine whether an attribute is of type ID. In case we have DTD(s) then this is done if DTD loading has been requested. In the case of HTML documents parsed with the HTML parser, then ID detection is done systematically. - + @@ -10580,8 +10706,8 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) - Finds the last child node of that element which is a Element node Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. - + Find the last child node which is an element. Note that entity references are not expanded. + @@ -10770,8 +10896,8 @@ Could we use @subtypes for this?'/> - - Load an external entity, note that the use of this function for unparsed entities may generate problems + + @@ -10787,6 +10913,12 @@ Could we use @subtypes for this?'/> xmlLockLibrary() is used to take out a re-entrant lock on the libxml2 library. + + Find or create a handler matching the encoding. If no default or registered handler could be found, try to create a handler using iconv or ICU if supported. The handler must be closed with xmlCharEncCloseFunc. Available since 2.13.0. + + + + defined(LIBXML_DEBUG_ENABLED) Count the children of @node. @@ -10801,7 +10933,7 @@ Could we use @subtypes for this?'/> - a malloc() equivalent, with logging of the allocation info. + DEPRECATED: don't use @@ -10813,7 +10945,7 @@ Could we use @subtypes for this?'/> - a malloc() equivalent, with logging of the allocation info. + DEPRECATED: don't use @@ -10824,14 +10956,14 @@ Could we use @subtypes for this?'/> - show in-extenso the memory blocks allocated + DEPRECATED: This feature was removed. - + - the last nbBytes of memory allocated and not freed, useful for dumping the memory left allocated between two places at runtime. + DEPRECATED: This feature was removed. - + @@ -10867,9 +10999,9 @@ Could we use @subtypes for this?'/> - show a show display of the memory allocated, and dump the @nr last allocated areas which were not freed + DEPRECATED: This feature was removed. - + @@ -10878,7 +11010,7 @@ Could we use @subtypes for this?'/> - a strdup() equivalent, with logging of the allocation info. + DEPRECATED: don't use @@ -10889,7 +11021,7 @@ Could we use @subtypes for this?'/> - Dump in-extenso the memory blocks allocated to the file .memorylist + DEPRECATED: This feature was removed. @@ -11225,11 +11357,11 @@ Could we use @subtypes for this?'/> - Creation of a new node containing a CDATA block. - - - - + Create a CDATA section node. + + + + defined(LIBXML_CATALOG_ENABLED) @@ -11245,33 +11377,33 @@ Could we use @subtypes for this?'/> - Creation of a new character reference node. - - - + This function is MISNAMED. It doesn't create a character reference but an entity reference. Create an empty entity reference node. This function doesn't attempt to look up the entity in @doc. Entity names like '&entity;' are handled as well. + + + defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) - Creation of a new child element, added at the end of @parent children list. @ns and @content parameters are optional (NULL). If @ns is NULL, the newly created element inherits the namespace of @parent. If @content is non NULL, a child list containing the TEXTs and ENTITY_REFs node will be created. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references. XML special chars must be escaped first by using xmlEncodeEntitiesReentrant(), or xmlNewTextChild() should be used. - + Create a new child element and append it to a parent element. If @ns is NULL, the newly created element inherits the namespace of the parent. If provided, @content is expected to be a valid XML attribute value possibly containing character and entity references. Text and entity reference node will be added to the child element, see xmlNewDocNode. + - + - + - Use of this function is DISCOURAGED in favor of xmlNewDocComment. Creation of a new node containing a comment. - - + Use of this function is DISCOURAGED in favor of xmlNewDocComment. Create a comment node. + + - Creates a new XML document - - + Creates a new XML document. If version is NULL, "1.0" is used. + + - Creation of a new node containing a comment within a document. - + Create a comment node. + @@ -11284,69 +11416,69 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) - Creation of a new Fragment node. - - + Create a document fragment node. + + - Creation of a new node element within a document. @ns and @content are optional (NULL). NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't need entities support. - - - + Create an element node. If provided, @content is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. Only references are handled, nested elements, comments or PIs are not. See xmlNewDocRawNode for an alternative. General notes on object creation: Each node and all its children are associated with the same document. The document should be provided when creating nodes to avoid a performance penalty when adding the node to a document tree. Note that a document only owns nodes reachable from the root node. Unlinked subtrees must be freed manually. + + + - + - Creation of a new node element within a document. @ns and @content are optional (NULL). NOTE: @content is supposed to be a piece of XML CDATA, so it allow entities references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't need entities support. - - - + Create an element node. Like xmlNewDocNode, but the @name string will be used directly without making a copy. Takes ownership of @name which will also be freed on error. + + + - + - Creation of a processing instruction element. - - - - + Create a processing instruction object. + + + + - Create a new property carried by a document. NOTE: @value is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewProp() if you don't need entities support. - - + Create an attribute object. If provided, @value is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. If you want to pass a raw string, see xmlNewProp. + + - + defined(LIBXML_TREE_ENABLED) - Creation of a new node element within a document. @ns and @content are optional (NULL). - - - + Create an element node. If provided, @value should be a raw, unescaped string. + + + - + - Creation of a new text node within a document. - - - + Create a new text node. + + + - Creation of a new text node with an extra content length parameter. The text node pertain to a given document. - - - - + Create a new text node. + + + + - Creation of a new DTD for the external subset. To create an internal subset, use xmlCreateIntSubset(). - - - - - + Create a DTD node. If a document is provided, it is an error if it already has an external subset. If the document has no external subset, it will be set to the created DTD. To create an internal subset, use xmlCreateIntSubset(). + + + + + Allocate an element content structure. Deprecated in favor of xmlNewDocElementContent @@ -11368,7 +11500,7 @@ Could we use @subtypes for this?'/> DEPRECATED: Internal function, do not use. Create a new input stream based on an xmlEntityPtr - + defined(LIBXML_LEGACY_ENABLED) @@ -11382,7 +11514,7 @@ Could we use @subtypes for this?'/> Create a new input stream structure encapsulating the @input into a stream suitable for the parser. - + @@ -11401,45 +11533,45 @@ Could we use @subtypes for this?'/> - Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of xmlNewDocNode. - - + Create an element node. Use of this function is DISCOURAGED in favor of xmlNewDocNode. + + - Creation of a new node element. @ns is optional (NULL). Use of this function is DISCOURAGED in favor of xmlNewDocNodeEatName. - - + Create an element node. Use of this function is DISCOURAGED in favor of xmlNewDocNodeEatName. Like xmlNewNode, but the @name string will be used directly without making a copy. Takes ownership of @name which will also be freed on error. + + - Creation of a new Namespace. This function will refuse to create a namespace with a similar prefix than an existing one present on this node. Note that for a default namespace, @prefix should be NULL. We use href==NULL in the case of an element creation where the namespace was not defined. - - + Create a new namespace. For a default namespace, @prefix should be NULL. The namespace URI in @href is not checked. You should make sure to pass a valid URI. If @node is provided, it must be an element node. The namespace will be appended to the node's namespace declarations. It is an error if the node already has a definition for the prefix or default namespace. + + - + - Create a new property tagged with a namespace and carried by a node. - - - - - + Create an attribute object. If provided, @value should be a raw, unescaped string. If @node is provided, the created attribute will be appended without checking for duplicate names. It is an error if @node is not an element. + + + + + - Create a new property tagged with a namespace and carried by a node. - - - - - + Like xmlNewNsProp, but the @name string will be used directly without making a copy. Takes ownership of @name which will also be freed on error. + + + + + - Creation of a processing instruction element. Use of this function is DISCOURAGED in favor of xmlNewDocPI. - - - + Create a processing instruction node. Use of this function is DISCOURAGED in favor of xmlNewDocPI. + + + Allocate and initialize a new parser context. @@ -11447,24 +11579,24 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) - Create a new property carried by a node. - - + Create an attribute node. If provided, @value should be a raw, unescaped string. If @node is provided, the created attribute will be appended without checking for duplicate names. It is an error if @node is not an element. + + - + xmlRNewMutex() is used to allocate a reentrant mutex for use in synchronizing access to data. token_r is a re-entrant lock and thus useful for synchronizing access to data structures that may be manipulated in a recursive fashion. - Creation of a new reference node. - - - + Create a new entity reference node, linking the result with the entity in @doc if found. Entity names like '&entity;' are handled as well. + + + - Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data. + Allocate and initialize a new SAX parser context. If userData is NULL, the parser context will be passed as user data. Available since 2.11.0. If you want support older versions, it's best to invoke xmlNewParserCtxt and set ctxt->sax with struct assignment. @@ -11476,24 +11608,24 @@ Could we use @subtypes for this?'/> - Creation of a new text node. Use of this function is DISCOURAGED in favor of xmlNewDocText. - - + Create a text node. Use of this function is DISCOURAGED in favor of xmlNewDocText. + + defined(LIBXML_TREE_ENABLED) - Creation of a new child element, added at the end of @parent children list. @ns and @content parameters are optional (NULL). If @ns is NULL, the newly created element inherits the namespace of @parent. If @content is non NULL, a child TEXT node will be created containing the string @content. NOTE: Use xmlNewChild() if @content will contain entities that need to be preserved. Use this function, xmlNewTextChild(), if you need to ensure that reserved XML chars that might appear in @content, such as the ampersand, greater-than or less-than signs, are automatically replaced by their XML escaped entity representations. - + Create a new child element and append it to a parent element. If @ns is NULL, the newly created element inherits the namespace of the parent. If @content is provided, a text node will be added to the child element, see xmlNewDocRawNode. + - + - + - Use of this function is DISCOURAGED in favor of xmlNewDocTextLen. Creation of a new text node with an extra parameter for the content's length - - - + Use of this function is DISCOURAGED in favor of xmlNewDocTextLen. + + + defined(LIBXML_READER_ENABLED) @@ -11562,11 +11694,11 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) - Finds the first closest next sibling of the node which is an element node. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. - + Find the closest following sibling which is a element. Note that entity references are not expanded. + - + A specific entity loader disabling network accesses, though still allowing local catalog accesses for resolution. @@ -11575,13 +11707,13 @@ Could we use @subtypes for this?'/> Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported. - + Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported. - + @@ -11613,12 +11745,27 @@ Could we use @subtypes for this?'/> + + Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. The returned value must be freed by the caller. Available since 2.13.0. + + + + + + - Searches for the BASE URL. The code should work on both XML and HTML document even if base mechanisms are completely different. It returns the base as defined in RFC 2396 sections 5.1.1. Base URI within Document Content and 5.1.2. Base URI from the Encapsulating Entity However it does not return the document base (5.1.3), use doc->URL in this case + See xmlNodeGetBaseSafe. This function doesn't allow to distinguish memory allocation failures from a non-existing base. + + Searches for the BASE URL. The code should work on both XML and HTML document even if base mechanisms are completely different. It returns the base as defined in RFC 2396 sections 5.1.1. Base URI within Document Content and 5.1.2. Base URI from the Encapsulating Entity However it does not return the document base (5.1.3), use doc->URL in this case Available since 2.13.0. + + + + + Read the value of a node, this can be either the text carried directly by this node if it's a TEXT node or the aggregate string of the values carried by this node child's (TEXT and ENTITY_REF). Entity references are substituted. @@ -11641,36 +11788,36 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) - Builds the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs, contrary to xmlNodeListGetString() this function doesn't do any character encoding handling. - - - - + Serializes attribute children (text and entity reference nodes) into a string. An empty list produces an empty string. If @inLine is true, entity references will be substituted. Otherwise, entity references will be kept and special characters like '&' will be escaped. + + + + - Build the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs - - - - + Serializes attribute children (text and entity reference nodes) into a string. An empty list produces an empty string. If @inLine is true, entity references will be substituted. Otherwise, entity references will be kept and special characters like '&' as well as non-ASCII chars will be escaped. See xmlNodeListGetRawString for an alternative option. + + + + defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) Set (or reset) the base URI of a node, i.e. the value of the xml:base attribute. - + - Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars(). - + Replace the text content of a node. Sets the raw text content of text, CDATA, comment or PI nodes. For element and attribute nodes, removes all children and replaces them by parsing @content which is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. Unfortunately, there isn't an API to pass raw content directly. An inefficient work-around is to escape the content with xmlEncodeSpecialChars before passing it. A better trick is clearing the old content with xmlNodeSetContent(node, NULL) first and then calling xmlNodeAddContent(node, content). Unlike this function, xmlNodeAddContent accepts raw text. + defined(LIBXML_TREE_ENABLED) - Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars(). - + See xmlNodeSetContent. + @@ -11678,7 +11825,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) Set the language of a node, i.e. the values of the xml:lang attribute. - + @@ -11692,7 +11839,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) Set (or reset) the space preserving behaviour of a node, i.e. the value of the xml:space attribute. - + @@ -11702,14 +11849,21 @@ Could we use @subtypes for this?'/> - This function is obsolete. Please see xmlURIFromPath in uri.c for a better solution. - + DEPRECATED: This never really worked. + + + Find or create a handler matching the encoding. If no default or registered handler could be found, try to create a handler using iconv or ICU if supported. The handler must be closed with xmlCharEncCloseFunc. Available since 2.13.0. + + + + + defined(LIBXML_OUTPUT_ENABLED) flushes and close the output I/O channel and free up all the associated resources - + @@ -11865,14 +12019,14 @@ Could we use @subtypes for this?'/> defined(LIBXML_SAX1_ENABLED) - Parse a well-balanced chunk of an XML document called by the parser The allowed sequence for the Well Balanced Chunk is the one defined by the content production in the XML grammar: [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)* - + Parse a well-balanced chunk of an XML document The allowed sequence for the Well Balanced Chunk is the one defined by the content production in the XML grammar: [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)* + - + @@ -11904,11 +12058,11 @@ Could we use @subtypes for this?'/> defined(LIBXML_PUSH_ENABLED) - Parse a Chunk of memory - + Parse a chunk of memory in push parser mode. Assumes that the parser context was initialized with xmlCreatePushParserCtxt. The last chunk, which will often be empty, must be marked with the @terminate flag. With the default SAX callbacks, the resulting document will be available in ctxt->myDoc. This pointer will not be freed by the library. If the document isn't well-formed, ctxt->myDoc is set to NULL. The push parser doesn't support recovery mode. + - - + + @@ -11917,17 +12071,17 @@ Could we use @subtypes for this?'/> - Parse a content sequence. Stops at EOF or '</'. [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)* + Parse XML element content. This is useful if you're only interested in custom SAX callbacks. If you want a node list, use xmlParseInNodeContext. Parse an external general entity within an existing parsing context An external general parsed entity is well-formed if it matches the production labeled extParsedEnt. [78] extParsedEnt ::= TextDecl? content - + - + defined(LIBXML_VALID_ENABLED) @@ -11954,8 +12108,8 @@ Could we use @subtypes for this?'/> - parse an XML document (and build a tree if using the standard SAX interface). [1] document ::= prolog element Misc* [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)? - + Parse an XML document and invoke the SAX handlers. This is useful if you're only interested in custom SAX callbacks. If you want a document tree, use xmlCtxtParseDocument. + @@ -12015,7 +12169,7 @@ Could we use @subtypes for this?'/> - DEPRECATED: Internal function, don't use. Parse an entitiy reference. Always consumes '&'. [68] EntityRef ::= '&' Name ';' [ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", the Name given in the entity reference must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot. The declaration of a parameter entity must precede any reference to it. Similarly, the declaration of a general entity must precede any reference to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'. [ WFC: Parsed Entity ] An entity reference must not contain the name of an unparsed entity + DEPRECATED: Internal function, don't use. @@ -12043,7 +12197,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_SAX1_ENABLED) - Parse an external general entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt. [78] extParsedEnt ::= TextDecl? content + DEPRECATED: Use xmlParseCtxtExternalEntity. Parse an external general entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt. [78] extParsedEnt ::= TextDecl? content @@ -12051,7 +12205,7 @@ Could we use @subtypes for this?'/> - + DEPRECATED: Internal function, don't use. Parse an External ID or a Public ID NOTE: Productions [75] and [83] interact badly since [75] can generate 'PUBLIC' S PubidLiteral S SystemLiteral [75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral [83] PublicID ::= 'PUBLIC' S PubidLiteral @@ -12194,6 +12348,12 @@ Could we use @subtypes for this?'/> + + Parse an URI based on RFC 3986 URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] Available since 2.13.0. + + + + DEPRECATED: Internal function, don't use. parse the XML version. [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ") [25] Eq ::= S? '=' S? @@ -12251,19 +12411,19 @@ Could we use @subtypes for this?'/> - Create a buffered parser input for the progressive parsing for the input from a file descriptor + Create a buffered parser input for the progressive parsing for the input from a file descriptor The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on. - + - Create a buffered parser input for the progressive parsing of a FILE * buffered C I/O + Create a buffered parser input for the progressive parsing of a FILE * buffered C I/O The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on. - + - Create a buffered parser input for the progressive parsing of a file If filename is "-' then we use stdin as the input. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. Do an encoding check if enc == XML_CHAR_ENCODING_NONE + Create a buffered parser input for the progressive parsing of a file Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. Do an encoding check if enc == XML_CHAR_ENCODING_NONE @@ -12280,23 +12440,23 @@ Could we use @subtypes for this?'/> - Create a buffered parser input for the progressive parsing for the input from an I/O handler + Create a buffered parser input for the progressive parsing for the input from an I/O handler The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on. - + - Create a buffered parser input for the progressive parsing for the input from a memory area. - + Create a parser input buffer for parsing from a memory area. This function makes a copy of the whole input buffer. If you are sure that the contents of the buffer will remain valid until the document was parsed, you can avoid the copy by using xmlParserInputBufferCreateStatic. The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on. + - + - DEPRECATED: Use xmlParserInputBufferCreateMem. - + Create a parser input buffer for parsing from a memory area. This functions assumes that the contents of the input buffer remain valid until the document was parsed. Use xmlParserInputBufferCreateMem otherwise. The encoding argument is deprecated and should be set to XML_CHAR_ENCODING_NONE. The encoding can be changed with xmlSwitchEncoding or xmlSwitchEncodingName later on. + @@ -12343,12 +12503,12 @@ Could we use @subtypes for this?'/> - Displays current context within the input content for error tracking + DEPRECATED: Use xmlFormatError. Displays current context within the input content for error tracking - Displays the associated file and line information for the current input + DEPRECATED: Use xmlFormatError. Displays the associated file and line information for the current input @@ -12378,6 +12538,16 @@ Could we use @subtypes for this?'/> + + defined(LIBXML_PATTERN_ENABLED) + Compile a pattern. Available since 2.13.0. + + + + + + + defined(LIBXML_PATTERN_ENABLED) Check if the pattern must be looked at from the root. @@ -12445,8 +12615,8 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) - Finds the first closest previous sibling of the node which is an element node. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. - + Find the closest preceding sibling which is a element. Note that entity references are not expanded. + @@ -12456,7 +12626,7 @@ Could we use @subtypes for this?'/> - xmlPushInput: switch to a new input stream which is stacked on top of the previous one(s). + Push an input stream onto the stack. This makes the parser use an input returned from advanced functions like xmlNewInputURL or xmlNewInputMemory. @@ -12472,45 +12642,45 @@ Could we use @subtypes for this?'/> - parse an XML in-memory document and build a tree. + Convenience function to parse an XML document from a zero-terminated string. See xmlCtxtReadDoc for details. - - + + - parse an XML from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the reader is closed or reset. + Parse an XML from a file descriptor and build a tree. See xmlCtxtReadFd for details. NOTE that the file descriptor will not be closed when the context is freed or reset. - - + + - parse an XML file from the filesystem or the network. + Convenience function to parse an XML file from the filesystem, the network or a global user-define resource loader. See xmlCtxtReadFile for details. - + - parse an XML document from I/O functions and source and build a tree. + Parse an XML document from I/O functions and context and build a tree. See xmlCtxtReadIO for details. - + - - + + - parse an XML in-memory document and build a tree. + Parse an XML in-memory document and build a tree. The input buffer must not contain a terminating null byte. See xmlCtxtReadMemory for details. - - + + @@ -12632,7 +12802,7 @@ Could we use @subtypes for this?'/> - a realloc() equivalent, with logging of the allocation info. + DEPRECATED: don't use @@ -12642,7 +12812,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) This function checks that all the namespaces declared within the given tree are properly declared. This is needed for example after Copy or Cut and then paste operations. The subtree may still hold pointers to namespace declarations outside the subtree or invalid/masked. As much as possible the function try to reuse the existing namespaces found in the new environment. If not possible the new namespaces are redeclared on @tree at the top of the given subtree. - + @@ -12774,7 +12944,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTTP_ENABLED) - By default, libxml submits HTTP output requests using the "PUT" method. Calling this method changes the HTTP output method to use the "POST" method instead. + DEPRECATED: Support for HTTP POST has been removed. @@ -12786,7 +12956,7 @@ Could we use @subtypes for this?'/> - Registers a callback for node creation + DEPRECATED: don't use Registers a callback for node creation @@ -12897,7 +13067,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_SCHEMAS_ENABLED) - Set the callback functions used to handle errors for a validation context + DEPRECATED: Use xmlRelaxNGSetParserStructuredErrors. Set the callback functions used to handle errors for a validation context @@ -12914,7 +13084,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_SCHEMAS_ENABLED) - Set the error and warning callback information + DEPRECATED: Use xmlRelaxNGSetValidStructuredErrors. Set the error and warning callback information @@ -12998,8 +13168,8 @@ Could we use @subtypes for this?'/> - Unlink and free one attribute, all the content is freed too Note this doesn't work for namespace definition attributes - + Unlink and free an attribute including all children. Note this doesn't work for namespace declarations. The attribute must have a non-NULL parent pointer. + @@ -13010,10 +13180,10 @@ Could we use @subtypes for this?'/> defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) - Unlink the old node from its current context, prune the new one at the same place. If @cur was already inserted in a document it is first unlinked from its existing context. See the note regarding namespaces in xmlAddChild. - + Unlink the old node. If @cur is provided, it is unlinked and inserted in place of @old. It is an error if @old has no parent. Unlike xmlAddChild, this function doesn't merge text nodes or delete duplicate attributes. See the notes in xmlAddChild. + - + Cleanup the error. @@ -13368,6 +13538,12 @@ Could we use @subtypes for this?'/> + + defined(LIBXML_OUTPUT_ENABLED) + Close a document saving context, i.e. make sure that all bytes have been output and free the associated data. Available since 2.13.0. + + + defined(LIBXML_OUTPUT_ENABLED) Flush a document saving context, i.e. make sure that all bytes have been output. @@ -13712,7 +13888,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_SCHEMAS_ENABLED) - Set the callback functions used to handle errors for a validation context + DEPRECATED: Use xmlSchemaSetParserStructuredErrors. Set the callback functions used to handle errors for a validation context @@ -13729,7 +13905,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_SCHEMAS_ENABLED) - Set the error and warning callback information + DEPRECATED: Use xmlSchemaSetValidStructuredErrors. Set the error and warning callback information @@ -14024,14 +14200,14 @@ Could we use @subtypes for this?'/> Search a Ns registered under a given name space for a document. recurse on the parents until it finds the defined namespace or return NULL otherwise. @nameSpace can be NULL, this is a search for the default namespace. We don't allow to cross entities boundaries. If you don't declare the namespace within those you will be in troubles !!! A warning is generated to cover this case. - + Search a Ns aliasing a given URI. Recurse on the parents until it finds the defined namespace or return NULL otherwise. - + @@ -14042,7 +14218,7 @@ Could we use @subtypes for this?'/> - set the default compression mode used, ZLIB based Correct values: 0 (uncompressed) to 9 (max compression) + DEPRECATED: Use xmlSetDocCompressMode set the default compression mode used, ZLIB based Correct values: 0 (uncompressed) to 9 (max compression) @@ -14052,13 +14228,13 @@ Could we use @subtypes for this?'/> - + defined(LIBXML_LEGACY_ENABLED) Set the function to call call back when a xml reference has been made - + Changes the defaultexternal entity resolver function for the application @@ -14072,22 +14248,22 @@ Could we use @subtypes for this?'/> - Function to reset the handler and the error context for out of context error messages. This simply means that @handler will be called for subsequent error messages while not parsing nor validating. And @ctx will be passed as first argument to @handler One can simply force messages to be emitted to another FILE * than stderr by setting @ctx to this file handle and @handler to NULL. For multi-threaded applications, this must be set separately for each thread. + DEPRECATED: See xmlSetStructuredErrorFunc for alternatives. Set the global "generic" handler and context for error messages. The generic error handler will only receive fragments of error messages which should be concatenated or printed to a stream. If handler is NULL, use the built-in default handler which prints to stderr. Since this is a global setting, it's a good idea to reset the error handler to its default value after collecting the errors you're interested in. For multi-threaded applications, this must be set separately for each thread. - update all nodes in the list to point to the right document - - - + Associate all subtrees in @list with a new document. Internal function, see xmlSetTreeDoc. + + + - Associate a namespace to a node, a posteriori. + Set the namespace of an element or attribute node. Passing a NULL namespace unsets the namespace. - + defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) @@ -14107,16 +14283,16 @@ Could we use @subtypes for this?'/> - Function to reset the handler and the error context for out of context structured error messages. This simply means that @handler will be called for subsequent error messages while not parsing nor validating. And @ctx will be passed as first argument to @handler For multi-threaded applications, this must be set separately for each thread. + DEPRECATED: Use a per-context error handler. It's recommended to use the per-context error handlers instead: - xmlCtxtSetErrorHandler (since 2.13.0) - xmlTextReaderSetStructuredErrorHandler - xmlXPathSetErrorHandler (since 2.13.0) - xmlXIncludeSetErrorHandler (since 2.13.0) - xmlSchemaSetParserStructuredErrors - xmlSchemaSetValidStructuredErrors - xmlRelaxNGSetParserStructuredErrors - xmlRelaxNGSetValidStructuredErrors Set the global "structured" handler and context for error messages. If handler is NULL, the error handler is deactivated. The structured error handler takes precedence over "generic" handlers, even per-context generic handlers. Since this is a global setting, it's a good idea to deactivate the error handler after collecting the errors you're interested in. For multi-threaded applications, this must be set separately for each thread. - update all nodes under the tree to point to the right document - - - + This is an internal function which shouldn't be used. It is invoked by functions like xmlAddChild, xmlAddSibling or xmlReplaceNode. @tree must be the root node of an unlinked subtree. Associate all nodes in a tree with a new document. Also copy strings from the old document's dictionary and remove ID attributes from the old ID table. + + + defined(LIBXML_SAX1_ENABLED) @@ -14131,7 +14307,7 @@ Could we use @subtypes for this?'/> Implements the XML shell This allow to load, validate, view, modify and save a document using a environment similar to a UNIX commandline. - + @@ -14260,7 +14436,7 @@ Could we use @subtypes for this?'/> - DEPRECATED: Internal function, do not use. skip all blanks character found at that point in the input streams. It pops up finished entities in the process if allowable at that point. + DEPRECATED: Internal function, do not use. Skip whitespace in the input stream. @@ -14277,10 +14453,10 @@ Could we use @subtypes for this?'/> - + - parse an XML qualified name string [NS 5] QName ::= (Prefix ':')? LocalPart [NS 6] Prefix ::= NCName [NS 7] LocalPart ::= NCName + DEPRECATED: This function doesn't report malloc failures. parse an XML qualified name string [NS 5] QName ::= (Prefix ':')? LocalPart [NS 6] Prefix ::= NCName [NS 7] LocalPart ::= NCName @@ -14418,7 +14594,7 @@ Could we use @subtypes for this?'/> - DEPRECATED: Internal function, don't use. Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';' + DEPRECATED: Internal function, don't use. @@ -14428,13 +14604,13 @@ Could we use @subtypes for this?'/> - Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs. - - - + DEPRECATED: Use xmlNodeSetContent. Parse an attribute value and build a node list containing only text and entity reference nodes. The resulting nodes will be associated with the document if provided. The document is also used to look up entities. The input is not validated. Syntax errors or references to undeclared entities will be ignored silently with unspecified results. + + + - DEPRECATED: Internal function, don't use. Takes a entity string content and process to do the adequate substitutions. [67] Reference ::= EntityRef | CharRef [69] PEReference ::= '%' Name ';' + DEPRECATED: Internal function, don't use. @@ -14445,11 +14621,11 @@ Could we use @subtypes for this?'/> - Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs. - - - - + DEPRECATED: Use xmlNodeSetContentLen. See xmlStringGetNodeList. + + + + length of a xmlChar's string @@ -14515,15 +14691,21 @@ Could we use @subtypes for this?'/> - Use encoding specified by enum to decode input data. This function can be used to enforce the encoding of chunks passed to xmlParseChunk. + Use encoding specified by enum to decode input data. This overrides the encoding found in the XML declaration. This function can also be used to override the encoding of chunks passed to xmlParseChunk. + + Use specified encoding to decode input data. This overrides the encoding found in the XML declaration. This function can also be used to override the encoding of chunks passed to xmlParseChunk. Available since 2.13.0. + + + + DEPRECATED: Internal function, don't use. Use encoding handler to decode input data. - + @@ -14534,15 +14716,15 @@ Could we use @subtypes for this?'/> - Concat the given string at the end of the existing node content + Concat the given string at the end of the existing node content. If @len is -1, the string length will be calculated. - Merge two text nodes into one - + Merge the second text node into the first. The second node is unlinked and freed. + @@ -14694,6 +14876,12 @@ Could we use @subtypes for this?'/> + + defined(LIBXML_READER_ENABLED) + Available since 2.13.0. + + + defined(LIBXML_READER_ENABLED) Provide the column number of the current parsing point. @@ -14957,7 +15145,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_READER_ENABLED) - Register a callback function that will be called on error and warnings. If @f is NULL, the default error and warning handlers are restored. + DEPRECATED: Use xmlTextReaderSetStructuredErrorHandler. Register a callback function that will be called on error and warnings. If @f is NULL, the default error and warning handlers are restored. @@ -15021,6 +15209,12 @@ Could we use @subtypes for this?'/> + + defined(LIBXML_WRITER_ENABLED) + Flushes and closes the output buffer. Available since 2.13.0. + + + defined(LIBXML_WRITER_ENABLED) End the current xml element. @@ -15619,101 +15813,101 @@ Could we use @subtypes for this?'/> - + - + - + - + - + - + defined(LIBXML_OUTPUT_ENABLED) - + - + - + - + - + - + - + - + - + defined(LIBXML_OUTPUT_ENABLED) - + - + - + - + defined(LIBXML_OUTPUT_ENABLED) @@ -16723,7 +16917,7 @@ Could we use @subtypes for this?'/> - This routine escapes a string to hex, ignoring reserved characters (a-z, A-Z, 0-9, "@-_.!~*'()") and the characters in the exception list. + This routine escapes a string to hex, ignoring unreserved characters a-z, A-Z, 0-9, "-._~", a few sub-delims "!*'()", the gen-delim "@" (why?) and the characters in the exception list. @@ -16777,13 +16971,13 @@ Could we use @subtypes for this?'/> Create a substring from a given UTF-8 string Note: positions are given in units of UTF-8 chars - + - Unlink a node from it's current context, the node is not freed If one need to free the node, use xmlFreeNode() routine after the unlink to discard it. Note that namespace nodes can't be unlinked as they do not have pointer to their parent. + Unlink a node from its tree. The node is not freed. Unless it is reinserted, it must be managed manually and freed eventually by calling xmlFreeNode. @@ -16808,14 +17002,14 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) - (Re)Build the automata associated to the content model of this element + DEPRECATED: Internal function, don't use. (Re)Build the automata associated to the content model of this element defined(LIBXML_VALID_ENABLED) - Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character. Also check VC: Standalone Document Declaration in P32, and update ctxt->valid accordingly + DEPRECATED: Internal function, don't use. Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character. Also check VC: Standalone Document Declaration in P32, and update ctxt->valid accordingly @@ -16843,7 +17037,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character. + DEPRECATED: Internal function, don't use. Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character. @@ -16852,7 +17046,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Try to validate a single attribute definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Default Legal ] - [ VC: Enumeration ] - [ VC: ID Attribute Default ] The ID/IDREF uniqueness and matching are done separately + DEPRECATED: Internal function, don't use. Try to validate a single attribute definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Default Legal ] - [ VC: Enumeration ] - [ VC: ID Attribute Default ] The ID/IDREF uniqueness and matching are done separately @@ -16860,7 +17054,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Validate that the given attribute value match the proper production [ VC: ID ] Values of type ID must match the Name production.... [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names ... [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names ... [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens. + DEPRECATED: Internal function, don't use. Validate that the given attribute value match the proper production [ VC: ID ] Values of type ID must match the Name production.... [ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names ... [ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names ... [ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens. @@ -16874,7 +17068,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Does the final step for the document validation once all the incremental validation steps have been completed basically it does the following checks described by the XML Rec Check all the IDREF/IDREFS attributes definition for validity + DEPRECATED: Internal function, don't use. Does the final step for the document validation once all the incremental validation steps have been completed basically it does the following checks described by the XML Rec Check all the IDREF/IDREFS attributes definition for validity @@ -16889,7 +17083,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Does the final step for the dtds validation once all the subsets have been parsed basically it does the following checks described by the XML Rec - check that ENTITY and ENTITIES type attributes default or possible values matches one of the defined entities. - check that NOTATION type attributes default or possible values matches one of the defined notations. + DEPRECATED: Internal function, don't use. Does the final step for the dtds validation once all the subsets have been parsed basically it does the following checks described by the XML Rec - check that ENTITY and ENTITIES type attributes default or possible values matches one of the defined entities. - check that NOTATION type attributes default or possible values matches one of the defined notations. @@ -16904,7 +17098,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Try to validate a single element definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: One ID per Element Type ] - [ VC: No Duplicate Types ] - [ VC: Unique Element Type Declaration ] + DEPRECATED: Internal function, don't use. Try to validate a single element definition basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: One ID per Element Type ] - [ VC: No Duplicate Types ] - [ VC: Unique Element Type Declaration ] @@ -16956,7 +17150,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Try to validate a single notation definition basically it does the following checks as described by the XML-1.0 recommendation: - it seems that no validity constraint exists on notation declarations But this function get called anyway ... + DEPRECATED: Internal function, don't use. Try to validate a single notation definition basically it does the following checks as described by the XML-1.0 recommendation: - it seems that no validity constraint exists on notation declarations But this function get called anyway ... @@ -16964,7 +17158,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) - Validate that the given name match a notation declaration. - [ VC: Notation Declared ] + DEPRECATED: Internal function, don't use. Validate that the given name match a notation declaration. - [ VC: Notation Declared ] @@ -16972,7 +17166,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Try to validate a single attribute for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately + DEPRECATED: Internal function, don't use. Try to validate a single attribute for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately @@ -16982,7 +17176,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Try to validate a single element and it's attributes, basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Element Valid ] - [ VC: Required Attribute ] Then call xmlValidateOneAttribute() for each attribute present. The ID/IDREF checkings are done separately + DEPRECATED: Internal function, don't use. Try to validate a single element and it's attributes, basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Element Valid ] - [ VC: Required Attribute ] Then call xmlValidateOneAttribute() for each attribute present. The ID/IDREF checkings are done separately @@ -16990,7 +17184,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Try to validate a single namespace declaration for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately + DEPRECATED: Internal function, don't use. Try to validate a single namespace declaration for an element basically it does the following checks as described by the XML-1.0 recommendation: - [ VC: Attribute Value Type ] - [ VC: Fixed Attribute Default ] - [ VC: Entity Name ] - [ VC: Name Token ] - [ VC: ID ] - [ VC: IDREF ] - [ VC: Entity Name ] - [ VC: Notation Attributes ] The ID/IDREF uniqueness and matching are done separately @@ -17001,7 +17195,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) - Pop the element end from the validation stack. + DEPRECATED: Internal function, don't use. Pop the element end from the validation stack. @@ -17010,7 +17204,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) - check the CData parsed for validation in the current stack + DEPRECATED: Internal function, don't use. check the CData parsed for validation in the current stack @@ -17018,7 +17212,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED) - Push a new element start on the validation stack. + DEPRECATED: Internal function, don't use. Push a new element start on the validation stack. @@ -17034,7 +17228,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_VALID_ENABLED) - Try to validate a the root element basically it does the following check as described by the XML-1.0 recommendation: - [ VC: Root Element Type ] it doesn't try to recurse or apply other check to the element + DEPRECATED: Internal function, don't use. Try to validate a the root element basically it does the following check as described by the XML-1.0 recommendation: - [ VC: Root Element Type ] it doesn't try to recurse or apply other check to the element @@ -17059,6 +17253,12 @@ Could we use @subtypes for this?'/> + + defined(LIBXML_XINCLUDE_ENABLED) + Available since 2.13.0. + + + defined(LIBXML_XINCLUDE_ENABLED) Creates a new XInclude context @@ -17114,6 +17314,14 @@ Could we use @subtypes for this?'/> + + defined(LIBXML_XINCLUDE_ENABLED) + Register a callback function that will be called on errors and warnings. If handler is NULL, the error handler will be deactivated. Available since 2.13.0. + + + + + defined(LIBXML_XINCLUDE_ENABLED) Set the flags used for further processing of XML resources. @@ -17283,7 +17491,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_XPATH_ENABLED) - Creates/frees an object cache on the XPath context. If activates XPath objects (xmlXPathObject) will be cached internally to be reused. @options: 0: This will set the XPath object caching: @value: This will set the maximum number of XPath objects to be cached per slot There are 5 slots for: node-set, string, number, boolean, and misc objects. Use <0 for the default number (100). Other values for @options have currently no effect. + Creates/frees an object cache on the XPath context. If activates XPath objects (xmlXPathObject) will be cached internally to be reused. @options: 0: This will set the XPath object caching: @value: This will set the maximum number of XPath objects to be cached per slot There are two slots for node-set and misc objects. Use <0 for the default number (100). Other values for @options have currently no effect. @@ -17381,7 +17589,7 @@ Could we use @subtypes for this?'/> Handle an XPath error - + defined(LIBXML_XPATH_ENABLED) @@ -18049,6 +18257,14 @@ Could we use @subtypes for this?'/> + + defined(LIBXML_XPATH_ENABLED) + Register a callback function that will be called on errors and warnings. If handler is NULL, the error handler will be deactivated. Available since 2.13.0. + + + + + defined(LIBXML_XPATH_ENABLED) Implement the starts-with() XPath function boolean starts-with(string, string) The starts-with function returns true if the first argument string starts with the second argument string, and otherwise returns false. @@ -18084,7 +18300,7 @@ Could we use @subtypes for this?'/> defined(LIBXML_XPATH_ENABLED) - Implement the substring-after() XPath function string substring-after(string, string) The substring-after function returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string, or the empty stringi if the first argument string does not contain the second argument string. For example, substring-after("1999/04/01","/") returns 04/01, and substring-after("1999/04/01","19") returns 99/04/01. + Implement the substring-after() XPath function string substring-after(string, string) The substring-after function returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string. For example, substring-after("1999/04/01","/") returns 04/01, and substring-after("1999/04/01","19") returns 99/04/01. diff --git a/doc/xmlcatalog.1 b/doc/xmlcatalog.1 index 0e1c1afed..38270cada 100644 --- a/doc/xmlcatalog.1 +++ b/doc/xmlcatalog.1 @@ -2,12 +2,12 @@ .\" Title: xmlcatalog .\" Author: John Fleck .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 11/04/2023 +.\" Date: 06/12/2024 .\" Manual: xmlcatalog Manual .\" Source: libxml2 .\" Language: English .\" -.TH "XMLCATALOG" "1" "11/04/2023" "libxml2" "xmlcatalog Manual" +.TH "XMLCATALOG" "1" "06/12/2024" "libxml2" "xmlcatalog Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/doc/xmllint.1 b/doc/xmllint.1 index 538bf4b81..855fef3fd 100644 --- a/doc/xmllint.1 +++ b/doc/xmllint.1 @@ -2,12 +2,12 @@ .\" Title: xmllint .\" Author: John Fleck .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 11/04/2023 +.\" Date: 06/12/2024 .\" Manual: xmllint Manual .\" Source: libxml2 .\" Language: English .\" -.TH "XMLLINT" "1" "11/04/2023" "libxml2" "xmllint Manual" +.TH "XMLLINT" "1" "06/12/2024" "libxml2" "xmllint Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -31,7 +31,7 @@ xmllint \- command line XML tool .SH "SYNOPSIS" .HP \w'\fBxmllint\fR\ 'u -\fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-quiet\fR | \fB\-\-shell\fR | \fB\-\-xpath\ "\fR\fB\fIXPath_expression\fR\fR\fB"\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-nodict\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-path\ "\fR\fB\fIPATH(S)\fR\fR\fB"\fR | \fB\-\-load\-trace\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fR\fB\fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fR\fB\fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fR\fB\fIFILE\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-max\-ampl\ \fR\fB\fIINTEGER\fR\fR | \fB\-\-maxmem\ \fR\fB\fINBBYTES\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fR\fB\fIENCODING\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fR\fB\fIPATTERNVALUE\fR\fR | \fB\-\-chkregister\fR | \fB\-\-relaxng\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schema\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-c14n\fR | \fB\-\-pedantic\fR] {\fIXML\-FILE(S)\fR... | \-} +\fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-quiet\fR | \fB\-\-shell\fR | \fB\-\-xpath\ "\fR\fB\fIXPath_expression\fR\fR\fB"\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-nodict\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-path\ "\fR\fB\fIPATH(S)\fR\fR\fB"\fR | \fB\-\-load\-trace\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fR\fB\fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fR\fB\fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fR\fB\fIFILE\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-max\-ampl\ \fR\fB\fIINTEGER\fR\fR | \fB\-\-maxmem\ \fR\fB\fINBBYTES\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fR\fB\fIENCODING\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fR\fB\fIPATTERNVALUE\fR\fR | \fB\-\-relaxng\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schema\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-c14n\fR | \fB\-\-pedantic\fR] {\fIXML\-FILE(S)\fR... | \-} .HP \w'\fBxmllint\fR\ 'u \fBxmllint\fR \fB\-\-help\fR .SH "DESCRIPTION" @@ -77,13 +77,6 @@ ${sysconfdir}/xml/catalog are used by default\&. .RE .PP -\fB\-\-chkregister\fR -.RS 4 -Turn on node registration\&. Useful for developers testing -\fBlibxml\fR(3) -node tracking code\&. -.RE -.PP \fB\-\-compress\fR .RS 4 Turn on @@ -357,7 +350,7 @@ the section called \(lqSHELL COMMANDS\(rq)\&. .PP \fB\-\-xpath "\fR\fB\fIXPath_expression\fR\fR\fB"\fR .RS 4 -Run an XPath expression given as argument and print the result\&. In case of a nodeset result, each node in the node set is serialized in full in the output\&. In case of an empty node set the "XPath set is empty" result will be shown and an error exit code will be returned\&. +Run an XPath expression given as argument and print the result\&. In case of a nodeset result, each node in the node set is serialized in full in the output\&. In case of an empty node set the "XPath set is empty" result will be shown and exit code 11 will be returned\&.\&. This feature is EXPERIMENTAL\&. Implementation details can change without futher notice\&. .RE .PP \fB\-\-stream\fR @@ -477,11 +470,6 @@ Leave the shell\&. Show this help\&. .RE .PP -\fBfree\fR -.RS 4 -Display memory usage\&. -.RE -.PP \fBload \fR\fB\fIFILENAME\fR\fR .RS 4 Load a new document with the given filename\&. @@ -599,13 +587,6 @@ Error in pattern (generated when option is used) .RE .PP -\fB8\fR -.RS 4 -Error in Reader registration (generated when -\fB\-\-chkregister\fR -option is used) -.RE -.PP \fB9\fR .RS 4 Out of memory error @@ -615,6 +596,11 @@ Out of memory error .RS 4 XPath evaluation error .RE +.PP +\fB11\fR +.RS 4 +XPath result is empty +.RE .SH "SEE ALSO" .PP \fBlibxml\fR(3) diff --git a/doc/xmllint.html b/doc/xmllint.html index e128c3930..dddbb8288 100644 --- a/doc/xmllint.html +++ b/doc/xmllint.html @@ -1,4 +1,4 @@ -xmllint

    Name

    xmllint — command line XML tool

    Synopsis

    xmllint [ --version | --debug | --quiet | --shell | --xpath "XPath_expression" | --debugent | --copy | --recover | --nodict | --noent | --noout | --nonet | --path "PATH(S)" | --load-trace | --htmlout | --nowrap | --valid | --postvalid | --dtdvalid URL | --dtdvalidfpi FPI | --timing | --output FILE | --repeat | --insert | --compress | --html | --xmlout | --push | --memory | --max-ampl INTEGER | --maxmem NBBYTES | --nowarning | --noblanks | --nocdata | --format | --encode ENCODING | --dropdtd | --nsclean | --testIO | --catalogs | --nocatalogs | --auto | --xinclude | --noxincludenode | --loaddtd | --dtdattr | --stream | --walker | --pattern PATTERNVALUE | --chkregister | --relaxng SCHEMA | --schema SCHEMA | --c14n | --pedantic ] { XML-FILE(S)... | - }

    xmllint --help

    DESCRIPTION

    +xmllint

    Name

    xmllint — command line XML tool

    Synopsis

    xmllint [ --version | --debug | --quiet | --shell | --xpath "XPath_expression" | --debugent | --copy | --recover | --nodict | --noent | --noout | --nonet | --path "PATH(S)" | --load-trace | --htmlout | --nowrap | --valid | --postvalid | --dtdvalid URL | --dtdvalidfpi FPI | --timing | --output FILE | --repeat | --insert | --compress | --html | --xmlout | --push | --memory | --max-ampl INTEGER | --maxmem NBBYTES | --nowarning | --noblanks | --nocdata | --format | --encode ENCODING | --dropdtd | --nsclean | --testIO | --catalogs | --nocatalogs | --auto | --xinclude | --noxincludenode | --loaddtd | --dtdattr | --stream | --walker | --pattern PATTERNVALUE | --relaxng SCHEMA | --schema SCHEMA | --c14n | --pedantic ] { XML-FILE(S)... | - }

    xmllint --help

    DESCRIPTION

    The xmllint program parses one or more XML files, specified on the command line as XML-FILE (or the standard input if the filename provided @@ -13,8 +13,6 @@ Otherwise XML catalogs starting from /etc/xml/catalog or, more specifically, ${sysconfdir}/xml/catalog are used by default. -

    --chkregister

    - Turn on node registration. Useful for developers testing libxml(3) node tracking code.

    --compress

    Turn on gzip(1) compression of output.

    --copy

    Test the internal copy implementation.

    --c14n

    @@ -97,7 +95,9 @@ result. In case of a nodeset result, each node in the node set is serialized in full in the output. In case of an empty node set the "XPath set is empty" result - will be shown and an error exit code will be returned. + will be shown and exit code 11 will be returned.. + This feature is EXPERIMENTAL. Implementation details can + change without futher notice.

    --stream

    Use streaming API - useful when used in combination with --relaxng or --valid options @@ -137,7 +137,7 @@ Dumps information about the node (namespace, attributes, content).

    du PATH

    Show the structure of the subtree under the given path or the current node. -

    exit

    Leave the shell.

    help

    Show this help.

    free

    Display memory usage.

    load FILENAME

    Load a new document with the given filename.

    ls PATH

    List contents of the given path or the current directory.

    pwd

    Display the path to the current node.

    quit

    Leave the shell.

    save FILENAME

    +

    exit

    Leave the shell.

    help

    Show this help.

    load FILENAME

    Load a new document with the given filename.

    ls PATH

    List contents of the given path or the current directory.

    pwd

    Display the path to the current node.

    quit

    Leave the shell.

    save FILENAME

    Save the current document to the given filename or to the original name.

    validate

    Check the document for errors.

    write FILENAME

    Write the current node to the given filename.

    ENVIRONMENT

    SGML_CATALOG_FILES

    SGML catalog behavior can be changed by redirecting queries to the user's own set of catalogs. This can be done by setting @@ -159,10 +159,7 @@ calling it from scripts.

    0

    No error

    1

    Unclassified

    2

    Error in DTD

    3

    Validation error

    4

    Validation error

    5

    Error in schema compilation

    6

    Error writing output

    7

    Error in pattern (generated when --pattern option is used) -

    8

    - Error in Reader registration (generated - when --chkregister option is used) -

    9

    Out of memory error

    10

    XPath evaluation error

    SEE ALSO

    libxml(3) +

    9

    Out of memory error

    10

    XPath evaluation error

    11

    XPath result is empty

    SEE ALSO

    libxml(3)

    More information can be found at

    • libxml(3) web page https://gitlab.gnome.org/GNOME/libxml2 From d5523d27eb65c9fb89c53a32b0e6219d81008c02 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 12 Jun 2024 15:37:17 +0200 Subject: [PATCH 503/504] Update NEWS --- NEWS | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) diff --git a/NEWS b/NEWS index 51c8318a8..2f7bbacef 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,284 @@ Some deprecated global variables were made const: - xmlDefaultSAXLocator - xmlParserDebugEntities +### Deprecations and removals + +- threads: Deprecate remaining ThrDef functions +- unicode: Deprecate most xmlUCSIs* functions +- memory: Remove memory debugging +- tree: Deprecate xmlRegisterNodeDefault +- tree: Deprecate xmlSetCompressMode +- html: Deprecate htmlHandleOmittedElem +- valid: Deprecate internal validation functions +- valid: Deprecate old DTD serialization API +- nanohttp: Deprecate public API +- Remove VMS support +- Remove Trio + +### Bug fixes + +- parser: Fix base URI of internal parameter entities +- tree: Handle predefined entities in xmlBufGetEntityRefContent +- schemas: Allow unlimited length decimals, integers etc. (Tomáš Ženčák) +- reader: Fix preservation of attributes +- parser: Always decode entities in namespace URIs +- relaxng: Fix tree corruption in xmlRelaxNGParseNameClass (Seiya Nakata) +- schemas: Fix ADD_ANNOTATION +- tree: Fix tree iteration in xmlDOMWrapRemoveNode +- tree: Declare namespace on clone in xmlDOMWrapCloneNode +- tree: Fix xmlAddSibling with last sibling +- tree: Fix xmlDocSetRootElement with multiple top-level elements +- catalog: Fetch XML catalog before dumping +- html: Don't close fd in htmlCtxtReadFd + +### Improvements + +- parser: Fix "Truncated multi-byte sequence" error +- Add missing _cplusplus processing clause (Sadaf Ebrahimi) +- parser: Rework handling of undeclared entities +- SAX2: Warn if URI resolution failed +- parser: Don't report error on invalid URI +- xmllint: Clean up option handling +- xmllint: Rework parsing +- parser: Don't create undeclared entity refs in substitution mode +- Make some globals const +- reader: Make xmlTextReaderReadString non-recursive +- reader: Rework xmlTextReaderRead{Inner,Outer}Xml +- Remove redundant size check (Niels Dossche) +- Remove redundant NULL check on cur (Niels Dossche) +- Remove always-false check old == cur (Niels Dossche) +- Remove redundant NULL check on cur (Niels Dossche) +- tree: Don't return empty localname in xmlSplitQName{2,3} +- xinclude: Don't try to fix base of non-elements +- tree: Don't coalesce text nodes in xmlAdd{Prev,Next}Sibling +- SAX2: Optimize appending children +- tree: Align xmlAddChild with other node insertion functions +- html: Use binary search in htmlEntityValueLookup +- io: Allocate output buffer with XML_BUFFER_ALLOC_IO +- encoding: Don't shrink input too early in xmlCharEncOutput +- tree: Tighten source doc check in xmlDOMWrapAdoptNode +- tree: Check destParent->doc in xmlDOMWrapCloneNode +- tree: Refactor text node updates +- tree: Refactor node insertion +- tree: Refactor element creation and parsing of attribute values +- tree: Simplify xmlNodeGetContent, xmlBufGetNodeContent +- buf: Don't use default buffer size for small strings +- string: Fix xmlStrncatNew(NULL, "") +- entities: Don't allow null name in xmlNewEntity +- html: Fix quadratic behavior in htmlNodeDump +- tree: Rewrite xmlSetTreeDoc +- valid: Rework xmlAddID +- tree: Remove unused node types +- tree: Make namespace comparison more consistent +- tree: Don't allow NULL name in xmlSetNsProp +- tree: Rework xmlNodeListGetString +- tree: Rework xmlTextMerge +- tree: Rework xmlNodeSetName +- tree: Simplify xmlAddChild with text parent +- tree: Disallow setting content of entity reference nodes +- tree: Rework xmlReconciliateNs +- schemas: fix spurious warning about truncated snprintf output + (Benjamin Gilbert) +- xmlschemastypes: Remove unreachable if statement (Maks Mishin) +- relaxng: Remove useless if statement (Maks Mishin) +- tree: Check for integer overflow in xmlStringGetNodeList +- http: Improve error message for HTTPS redirects +- catalog: Remove Windows hack +- save: Move DTD serialization code to xmlsave.c +- parser: Report fatal error if document entity couldn't be loaded +- xpath: Fix return of empty node-set in xmlXPathNodeCollectAndTest +- SAX2: Limit entity URI length to 2000 bytes +- parser: Account for full size of non-well-formed entities +- parser: Pop inputs if parsing DTD failed +- parser: Fix quadratic behavior when copying entities +- writer: Implement xmlTextWriterClose +- parser: Avoid duplicate namespace errors +- parser: Add XML_PARSE_NO_XXE parser option +- parser: Make xmlParseContent more useful +- error: Make xmlFormatError public +- encoding: Check whether encoding handlers support input/output +- SAX2: Enforce size limit in xmlSAX2Text with XML_PARSE_HUGE +- parser: Lower maximum entity nesting depth +- parser: Set depth limit to 2048 with XML_PARSE_HUGE +- parser: Implement xmlCtxtSetOptions +- parser: Always prefer option members over bitmask +- parser: Don't modify SAX2 handler if XML_PARSE_SAX1 is set +- parser: Rework parsing of attribute and entity values +- save: Output U+FFFD replacement characters +- parser: Simplify entity size accounting +- parser: Avoid unwanted expansion of parameter entities +- parser: Always copy content from entity to target +- parser: Simplify control flow in xmlParseReference +- parser: Remove xmlSetEntityReferenceFunc feature +- parser: Push general entity input streams on the stack +- parser: Move progressive flag into input struct +- parser: Fix in-parameter-entity and in-external-dtd checks +- xpath: Rewrite substring-before and substring-after +- xinclude: Only set xml:base if necessary +- xinclude: Allow empty nodesets +- parser: Rework general entity parsing +- io: Fix close error handling +- io: Fix read/write error handling +- io: More refactoring and unescaping fixes +- io: Move some code from xmlIO.c to parserInternals.c +- uri: Clean up special parsing modes +- xinclude: Rework xml:base fixup +- parser: Also set document properties when push parsing +- include: Move non-generated parts from xmlversion.h.in +- io: Remove support for HTTP POST +- dict: Move local RNG state to global state +- dict: Get random seed from system PRNG +- io: Don't use "-" to read from stdin +- io: Rework initialization +- io: Consolidate error messages +- xzlib: Fix harmless unsigned integer overflow +- io: Always use unbuffered input +- io: Fix detection of compressed streams +- io: Pass error codes from xmlFileOpenReal to xmlNewInputFromFile +- io: Rework default callbacks +- error: Stop printing some errors by default +- xpath: Don't free nodes of XSLT result value trees +- valid: Fix handling of enumerations +- parser: Allow recovery in xmlParseInNodeContext +- encoding: Support ASCII in xmlLookupCharEncodingHandler +- include: Remove useless 'const' from function arguments +- Avoid EDG -Wignored-qualifiers warnings on wrong 'const *' to '* const' + conversions (makise-homura) +- Avoid EDG deprecation warnings for LCC compiler (makise-homura) +- Avoid EDG -Woverflow warnings on truncating conversions by manually + truncating operand (makise-homura) +- Avoid EDG -Wtype-limits warnings on unsigned comparisons with zero by + conversion from unsigned int to int (makise-homura) +- Avoid using no_sanitize attribute on EDG even if compiler shows as GCC + (makise-homura) + +### Build systems + +- meson: convert boolean options to feature option (Rosen Penev) +- meson: Pass LIBXML_STATIC in dependency (Andrew Potter) +- meson: fix compilation with local binaries (Rosen Penev) +- meson: don't use dl dependency on old meson (Rosen Penev) +- meson: fix usage as a subproject (Rosen Penev) +- autotools: Fix pthread detection on FreeBSD +- build: Remove --with-fexceptions configuration option +- autotools: Remove --with-coverage configuration option +- build: Disable HTTP support by default +- Stop defining _REENTRANT +- doc: Don't install example code +- meson: Initial commit (Vincent Torri) +- build: Disable support for compression libraries by default +- Set LIBXML2_FOUND if it has been properly configured (Michele Bianchi) +- Makefile.am: omit $(top_builddir) from DEPS and LDADDS (Mike Dalessio) + +### Test suite + +- runtest: Work around broken EUC-JP support in musl iconv +- runtest: Check for IBM-1141 encoding handler +- fuzz: Add xmllint fuzzer +- fuzz: Add fuzzer for XML reader API +- fuzz: New tree API fuzzer +- tests: Remove testOOM +- Don't let gentest.py cast types to 'const somethingPtr' to avoid + -Wignored-qualifiers (makise-homura) + + +v2.12.8: Jun 12 2024 + +### Regressions + +- parser: Fix performance regression when parsing namespaces + + +v2.12.7: May 13 2024 + +### Security + +- [CVE-2024-34459] Fix buffer overread with `xmllint --htmlout` + +### Regressions + +- xmllint: Fix --pedantic option +- save: Handle invalid parent pointers in xhtmlNodeDumpOutput + + +v2.12.6: Mar 15 2024 + +### Regressions + +- parser: Fix detection of duplicate attributes in XML namespace +- xmlreader: Fix xmlTextReaderConstEncoding +- html: Fix htmlCreatePushParserCtxt with encoding +- xmllint: Return error code if XPath returns empty nodeset + + +v2.12.5: Feb 4 2024 + +### Security + +- [CVE-2024-25062] xmlreader: Don't expand XIncludes when backtracking + +### Regressions + +- parser: Fix crash in xmlParseInNodeContext with HTML documents + + +v2.12.4: Jan 15 2024 + +### Regressions + +- parser: Fix regression parsing standalone declarations +- autotools: Readd --with-xptr-locs configuration option +- parser: Fix build --without-output +- parser: Don't grow or shrink pull parser memory buffers +- io: Fix memory lifetime issue with input buffers + + +v2.12.3: Dec 12 2023 + +### Regressions + +- parser: Fix namespaces redefined from default attributes + +### Build fixes + +- include: Rename XML_EMPTY helper macro +- include: Move declaration of xmlInitGlobals +- include: Add missing includes +- include: Move globals from xmlsave.h to parser.h +- include: Readd circular dependency between tree.h and parser.h + + +v2.12.2: Dec 5 2023 + +### Regressions + +- parser: Fix invalid free in xmlParseBalancedChunkMemoryRecover +- globals: Disable TLS in static Windows builds +- html: Reenable buggy detection of XML declarations +- tree: Fix regression when copying DTDs +- parser: Make CRLF increment line number + +### Build fixes + +- build: Disable compiler TLS by default +- cmake: Update config.h.cmake.in +- tests: Fix tests --with-valid --without-xinclude + + +v2.12.1: Nov 23 2023 + +### Regressions + +- hash: Fix deletion of entries during scan +- parser: Only enable SAX2 if there are SAX2 element handlers + +### Build fixes + +- autotools: Stop checking for snprintf +- dict: Fix '__thread' before 'static' +- fix: pthread weak references in globals.c (Mike Dalessio) +- tests: Fix build with older MSVC + v2.12.0: Nov 16 2023 From cdd2575f7fbab1d8162600f4048bc37503c80e28 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 12 Jun 2024 15:45:38 +0200 Subject: [PATCH 504/504] Release v2.13.0 --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2f7bbacef..a76ffbb7c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ NEWS file for libxml2 -v2.13.0: not released yet +v2.13.0: Jun 12 2024 ### Major changes